Table of Contents

Flex Sensor Interfacing with Quarky

Example Description
Learn how to interface a flex sensor with Quarky, the versatile microcontroller, to detect bending or flexing.
INTRODUCTION

The flex sensor is an ingenious device employing carbon on a plastic strip to serve as a variable resistor. As the sensor bends in one direction, its resistance varies accordingly. The more it bends, the higher the resistance becomes. This unique property makes it an ideal choice for applications where detecting bending or flexing is necessary.

In this example, we will be interfacing a flex sensor with Quarky and based on the change in its resistance we’ll be controlling the movement of our servomotor.

Circuit Diagram

 

Code

  1. Open Pictoblox and create a new file.
  2. Select Quarky from the board menu
  3. Create a variable called “sensor value” and set it to 0
  4. Add a “forever” block from the control palette.
  5. Inside the “forever” block, set “sensor value” to read analog sensor at A1.
  6. To convert this range to 0-180 for controlling the servo motor, use the “map” block from the Quarky palette and insert the sensor value in place of 50.
  7. Create another variable as “Servo angle”, Set the mapped value as the value of our new variable.
  8. connect servo at port servo 1 and fed variable servo angle as for the servo motor.
  9. Finally, add a “when flag clicked” event to complete the script and initiate the servo control with the flex sensor.

Script

OUTPUT

 

Output GIFs are need to be updated