## Introduction: 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)

- Jumper wires

- Pillow * 1

- scissor

## Step 1: Build the Circuit

Follow the circuit in the pictures above.

## Step 2: Type the Code In

The part I changed is the time that the LED shines, I changed it from 100ms to 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

}

//fade from the highest to the lowest

for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)

{

digitalWrite(thisPin,LOW);//turn this led off

for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)

{

digitalWrite(thisPin,HIGH);//turn this led on

for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)

{

digitalWrite(thisPin,LOW);//turn this led off

}

## Step 3: 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

## Step 4: 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/