hi everyone,after reading allmost all post around here and google,hope 2 get my answers here.I found hundred of examples of Ir conected to Atmegas that light up a Led when get close to object,but not even one example on how to make a toogle switch.Im not the only one looking for codes like this,truth is this subject is avoided,anyway..I wanna do a simple toogle switch,with the arduino Duemilanove and the Sharp 2Y0A21 ir sensor,that can light a Led.So far i can only make it like momentary switch: +LED on pin 13 +DATA from ir on pin analog 0 ---------------------------------- int led1 = 13; int sensor = A0;
void loop() { // we read the sensor Value int Value = analogRead(A0); // we maps the value int sensorValue = map(Value, 0, 1024, 0 , 200); // turn on the led1 when the value is beetween 50 and 100 if ( sensorValue > 50 && sensorValue <300){ digitalWrite(13, HIGH);
}
else { // turn off the two leds digitalWrite(13, LOW);