const int ledPin1 = 11; // the number of the LED pin
const int ledPin2 = 10; // the number of the LED pin
int sensorPin = A0;
int sensorValue = 0; // variables will change:
void setup()
{ // initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
Serial.begin(9600); //sets the data rate for serial data transmission:
}
void loop()
{ // read the state of the sensor value:
sensorValue = analogRead(sensorPin);
if (sensorValue > 400)
{
// turn LED1 on:
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
delay(100); //delay period equal to 0.1 second
}
else
{ // turn LED1 off:
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(100);
}
Serial.print("\n sensor = ");
Serial.print(sensorValue);
}