Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code for Interfacing Flex Sensor with Arduino and controlling an LED.
const int flexPin = A0;
const int ledPin = 7;
void setup()
{
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop()
{
int flexValue;
flexValue = analogRead(flexPin);
Serial.print("sensor: ");
Serial.println(flexValue);
if(flexValue>890)
digitalWrite(ledPin,HIGH);
else
digitalWrite(ledPin,LOW);
delay(20);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment