Reading the serial data using Arduino
You can read incoming data from the serial port where we wrote data using the Python script in the previous section using Arduino. The following Arduino sketch will read the incoming data from the serial port and turn on the PowerSwitch Tail if it finds 1
, and turn off the PowerSwich Tail if it finds 0
.
The sample code, B04844_07_01.ino
, can be found in the Chapter 7
codes folder, so you can copy and paste it on a new Arduino IDE and upload it to your Arduino UNO board.
Connecting the PowerSwitch Tail with Arduino
Connect the PowerSwitch Tail to your Arduino UNO board, as shown in the following Fritzing diagram. For this project, we will use a 240V AC PowerSwitch Tail:
Using a hook-up wire, connect the Arduino digital pin 5 with the PowerSwitch Tail positive (+ in) connecter.
Using another hook-up wire, connect the Arduino ground pin with the PowerSwitch Tail negative (- in) connector.
Connect a 240V AC light bulb to the LOAD end of the PowerSwitch Tail.
Connect...