I am trying to power an LED using an Arduino Nano and I can't seem to get the LED to light up. I have a flex sensor connected to the Nano, which when it is bent to a certain point, the LED should light up by making pin 3 an output. Does anyone understand why this isn't working? Here is my code
int flexSensorPin1 = A1; //analog pin 0
int flexSensorPin2 = A2;
int flexSensorRead1;
int flexSensorRead2;
int LEDPower = 3;
int flexADJ1;
int flexADJ2;
void setup(){
Serial.begin(9600);
pinMode(flexSensorPin1,INPUT);
pinMode(flexSensorPin2,INPUT);
pinMode(LEDPower,OUTPUT);
}
void loop(){
flexSensorRead1 = analogRead(flexSensorPin1);
flexSensorRead2 = analogRead(flexSensorPin2);
flexADJ1 = map(flexSensorRead1, 0, 1023, 0, 100);
flexADJ2 = map(flexSensorRead2, 0, 1023, 60, 100);
if (Serial.read() == '1'){
Serial.println(flexADJ1);
Serial.println(flexADJ2);
}
if (flexADJ1 <= 80){
analogWrite(LEDPower,HIGH);
digitalWrite(13,HIGH);
delay(10);
}
else {
analogWrite(LEDPower,LOW);
digitalWrite(13,LOW);
}
}