Arduino Reading Light Detector

9B J05176 陳夏櫻

 This Arduino project is a light detector that informs a person about whether the light they’re exposed under is suitable for reading.

 When the intensity of surrounding light is acceptable, the green flower would light up (contains blue and green LED); when the light is a bit dim, the white flower would shine(white LED); when the light is too dark and is harmful to your eyes, the orange flower would brighten.

Step 1: Materials & Circuit & Code

Prepare the Materials and Construct the Circuit

Note: the circuit diagram doesn't include female to male jumper wires. Add these wires in the place between LED and photoresistor with the breadboard.

Code: (you may decide what ways would you like the LEDs to glow by changing the codes)

void setup()
{ Serial.begin(9600); pinMode( 2, OUTPUT); pinMode( 4, OUTPUT); }

void loop() { Serial.print(analogRead( A0 )); Serial.print(" "); Serial.println(); delay( 20 ); if (( ( analogRead( A0 ) ) < ( 400 ) )) { analogWrite(12 , random( 206 , 256 )); analogWrite(10 , random( 206 , 256 )); } else { analogWrite( 12, 0 ); analogWrite( 10 , 0 ); }

if (( ( ( analogRead( A0 ) ) > ( 400 ) ) && ( ( analogRead( A0 ) ) < ( 800 ) ) )) { analogWrite(6 , random( 127 , 140 )); analogWrite(8 , random( 127 , 140 )); } else { analogWrite( 6, 0 ); analogWrite( 8 , 0 ); }

if (( ( analogRead( A0 ) ) > ( 800 ) )) { digitalWrite (2, HIGH) ; digitalWrite (4, HIGH) ; } else { digitalWrite( 2, LOW ); digitalWrite( 4 , LOW ); } }

Step 2: Box Editing

1. Use utility knives to cut 4 holes on top of the box, adjust the hole's size by trying whether the LED or photoresistor connected by jumper wires can go through it.

Cut another hole on the side where photoresistor is. (Adjust the size by seeing if it's large enough for you to plug in the USB cable to Leonardo.)

2. (Optional: Stick some duct tapes to cover up the box, and stick a white paper on top - write words on it with a marking pen to show what each flower symbolizes)

Step 3: Place Your Leonardo and Breadboard Into the Box

Plug the LEDs and photoresistor to its hole (blue and green LED in the right, two white in the middle, and red and orange in the left, with photoresistor in the smallest hole.)

Step 4: Construction of Paper Flowers

Fold paper flowers to decorate the LEDs (after folding, enlarge the hole at the bottom with any pen to allow LEDs to be placed in)

Click this link for instructions on folding paper flowers: https://www.wikihow.com/Fold-Paper-Flowers

Step 5: Congratulations!

Place the flowers on top of the LEDs, plug in the USB cable, upload the code to Arduino, and you're DONE!

Share

    Recommendations

    • Pets Challenge

      Pets Challenge
    • Backyard Contest

      Backyard Contest
    • Frozen Treats Challenge

      Frozen Treats Challenge

    Discussions