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
- Open Pictoblox and create a new file.
- Select Quarky from the board menu
- Create a variable called “sensor value” and set it to 0
- Add a “forever” block from the control palette.
- Inside the “forever” block, set “sensor value” to read analog sensor at A1.
- 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.
- Create another variable as “Servo angle”, Set the mapped value as the value of our new variable.
- connect servo at port servo 1 and fed variable servo angle as for the servo motor.
- 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