How to control a lamp via Arduino

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.

Ingredients:

The circuit and the code it’s super easy and it’s on GitHub.

Code explanation:

  1. in setup() we declare that pin 7 is an output
  2. in loop() we turn on pin 7
  3. We wait 10000 milliseconds (10 seconds) before running next instruction
  4. We turn off pin 7
  5. We wait another 100000 milliseconds
  6. 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.

Leave a Reply