Coding Blog

When a switch meets Arduino

After building a wearable led switch, I’ve built an interactive switch which I use tongs to turn on the led light.

Connecting Arduino and the switch already made, it could successfully light each color that I typed in Arduino program. There are 7 colors—red, orange, yellow, green, cyan, blue, magenta—that I typed in. By this experiment, the colors of the led light will depict how much energy is left.

Here’s the Arduino code that I typed.

int photoresistor; //variable for storing the photoresistor valueint potentiometer; //variable for storing the photoresistor valueint threshold = 700; //if the photoresistor reading is lower than this value the light wil turn on