Flowing LED Lights Pillow
by claire833.sung in Circuits > Arduino
457 Views, 0 Favorites, 0 Comments
Flowing LED Lights Pillow
In this experiment, I am doing a flowing LED light pillow. The project demands several simple components to make for it. The lights inside the pillow are with white and yellow colors, which will let you chill and have a good mood before sleeping.
Supplies
- Arduino Leonardo board * 1
- USB cable * 1
- Resistor (220Ω) * 8
- LED * 8 ( 4 white & 4 yellow lights)
- Breadboard * 1
- Jumper wires
- Pillow * 1
- scissor
Build the Circuit
Follow the circuit in the pictures above.
Type the Code In
The part I changed is the time that the LED shines, I changed it from 100ms to 200ms
我改變的地方是LED燈閃的時間,從原本的100ms到200ms
(picture 2 is the code analysis 圖二是程式碼註解照片)
Code:
//Flowing LED Lights
/* Eight LEDs will light up one by one from left to right, and then go out one by one from right to left.After that, the LEDs will light up one by one from right to left, and then go out one by one from left to right.This process will repeat indefinitely
/**************************************/
const int lowestPin = 2;//the lowest one attach to
const int highestPin = 9;//the highest one attach to
/**************************************/
void setup(){ //set pins 2 through 9 as output
for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)
{
pinMode(thisPin,OUTPUT); //initialize thisPin as an output
}
}
/****************************************/
void loop()
{
//iterate over the pins
//turn the led on from lowest to the highest
for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)
{
digitalWrite(thisPin,HIGH);//turn this led on
改 delay(200);//wait for 200 ms (原本是100 ms)
}
//fade from the highest to the lowest
for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)
{
digitalWrite(thisPin,LOW);//turn this led off
改 delay(200);//wait for 200 ms}
for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)
{
digitalWrite(thisPin,HIGH);//turn this led on
改 delay(200);//wait for 200 ms}
for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)
{
digitalWrite(thisPin,LOW);//turn this led off
改 delay(200);//wait for 200 ms}
}
Put the LED Lights in the Pillow
Use a scissor to cut holes on the sides of the pillow, then put the LED lights inside
Done!
It should look like this!
This project is a revised version from https://www.instructables.com/id/Flowing-LED-Lights-With-Arduino-Uno-R3/