In the last posts I wrote that I bought a lot of Arduino stuff, to try to build something interesting, but I didn’t show anything.
This is the first example, the easiest: how to control a lamp.
- An Arduino Uno
- A 5V relay and 220V contacts
- A lamp (I got a 12V one because it’s safer – remember if you plug in a 220V outlet it will explode)
The circuit and the code it’s super easy and it’s on GitHub.
- in setup() we declare that pin 7 is an output
- in loop() we turn on pin 7
- We wait 10000 milliseconds (10 seconds) before running next instruction
- We turn off pin 7
- We wait another 100000 milliseconds
- We start again from point 2
The result is that we have turn on and off the lamp every 10 seconds.
Obviously, this is an useless circuit, but we can expand it, for example by controlling the lamp via Bluetooth or via WiFi.