Introduction
Step 1
Step 2
Step 3
Code
Read moreThis project shows you to make a homemade flex sensor and control servos with it. My homemade flex sensor.
Lets make it. Take 13cm of 2 thick paper.
And also cut a 12 cm of 2 foil paper. Paste it together and paste to the other thick paper.
Now take a 13cm paper. And rub it with a pencil:
Stick the two thick paper together.
REMEMBER: Keep the paper inside the two thick papers. Don't touch the foil papers with each other.
Give one jumper wire to the foil paper and again to the other one.
Connect to the breadboard.
#include <Servo.h>
Servo servo1;
const int flexpin = A0;
void setup ()
{
Serial.begin(115200);
servo1.attach(9);
}
void loop ()
{
int flexposition;
int servoposition;
flexposition = analogRead(flexpin);
servoposition = map(flexposition, 1020, 1023, 0, 90);
servoposition = constrain(servoposition, 0, 90);
servo1.write(servoposition);
Serial.print("sensor: ");
Serial.print(flexposition);
Serial.print(" servo:");
Serial.println(servoposition);
delay(1000);
}
Upload it. Enjoy.
Comments