[mw_shl_code=c,true]unsigned char RedLight=12;
unsigned char GreenLight=13;
#define X 512
int SensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// put your setup code here, to run once:
pinMode(RedLight, OUTPUT);
pinMode(GreenLight, OUTPUT);
}
void loop() {
SensorValue = analogRead(sensorPin);
if( SensorValue>X )
{digitalWrite(RedLight, HIGH);
digitalWrite(GreenLight, LOW);
}
else
{ digitalWrite(RedLight, LOW);
digitalWrite(GreenLight, HIGH);
}[/mw_shl_code] |