Skip to content

Instantly share code, notes, and snippets.

@elktros
Created July 12, 2018 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/08561a79f77a18430a2874e3ab6e6fdb to your computer and use it in GitHub Desktop.
Save elktros/08561a79f77a18430a2874e3ab6e6fdb to your computer and use it in GitHub Desktop.
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