How to Code

How to Code

The code is very simple, you will first need to open a new sheet in your arduino app and then input the following:

//Include Servo library

Servo myservo; // create servo object to control a servo

void setup() {
myservo.attach(6); // attaches the servo on pin 6 to the servo object

// Configure flex sensor pin
pinMode(A0, INPUT_PULLUP);

void loop() {
int flexSensor = analogRead(A0);

/*Values from sensor are about 380 -> 550;
we need to convert this to about 0 -> 170
since my finger is too short to be affected
when the servo moves 180 degrees*/
int angle = (flexSensor - 380) / 1;


myservo.write(angle); // set servo position