Code for Interfacing Flex Sensor with Arduino and controlling an LED.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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