Start with Hardware
Arduino IR Sensor
First Step - setup
Initialise serial port
Deﬁne seven output pins , set them low
Deﬁne array with seven element, clear
all elements (put 0 there)
Second Step - Loop
Wait for serial data
Subtract Ascii code of ‘1’. if Value is 0 to
6. This is ‘I’, else display error message.
Toggle array element I
If new value is 00, Switch off output I,
else switch on output I
Display appropriate message on serial
Add LCD, IR
Display status of all seven outputs at
power on on LCD
When IR code is pressed, change output
and LCD Display.
Some students ﬁnd it diffult to
understand how to toggle a output.
It is like this. When we press a key, we
change one Variable by exclusive oring
with Binary 1. So if it was ‘0’ after
pressing key it becomes ‘1’
Now we check variable, if ‘0’ we set
output off, if ‘1’ we set output on.
For More Details
All data sheets and soruce code