Project 03:Street Lamps

Img

1. Introduction

Street lamps are ubiquitous in our daily life. For example, some public street lamps come on automatically at night and go off automatically during the day. Do you want to know why? Let’s make a small street lamp together.

Look at the tools first.

2. Components

Img

Img

Img

Kidsuno Mainboard×1

Photoresistor×1

White LED Module×1

Img

Img

Img

Connection Wire×2

USB Cable×1

Street Lamps×1

Img

3. Assembly Steps

Download the PDF follow the link:Street Lamp Assembly

Or you can Watch the assemble video :

4. Function: Detect the Light Intensity

Img

5. Wiring Diagram

Connect the kidsuno mainboard and computer via a USB cable, and connect the photoresistor to the No.7 interface of the mainboard and the LED module to the No.1 interface of the mainboard.

Img

6. Description of the the Building Blocks

Img

The block is used to set serial baud rate(generally, the baud rate 9600 is taken as an example)

Img

This block is used to set print mode for the serial port. warp means line feed printing, no-warp means no line feed printing, HEX means hexadecimal printing.

Img

It is used to read the analog signal value of the specified pin(range:0~1023)

7. Write the Program

① Drag the instruction blockImg in the Events module to the script area.

Img

② Drag the instruction blockImg in the Serial module to the script area and take the baud rate 9600 as an example.

Img

③ Drag the instruction blockImg in the Pins module to the script area. Since the photoresistor is connected to pin A0 of port 7 on the mainboard, then change the number 0 to A0.

Img

④ Drag the instruction block Img in the Control module to the script area.

Img

⑤ Drag the instruction blockImg in the Serial module to the script area.

Img

⑥ Drag the instruction blockImg in the Pins module to the script area and put it into the block Img.

Img

⑦ Drag the instruction blockImg in the Control module to the script area and change the number 1 to 0.3.

Img

⑧ Complete Program

Img

8. Test Result

Click Img to upload the complete program to the kidsuno mainboard and power up, then click Img in the serial monitor area to set the baud rate to 9600. Then the serial monitor will print the analog value read by the photoresistor. When the light intensity in the environment where the photoresistor is located gradually decreases, the analog value increases gradually, otherwise, the analog value decreases.

Img

Img

9. Function: Photoresistor Controls LED

Img

10. Description of the the Building Blocks

Img

It is a conditional statement code executing if-then-else function: If the logical judgment statement in Img is satisfied, the code statement below then is executed, otherwise, the code below else is executed.

11. Flow Chart

First, set the LED to off. When the light intensity value read by the photoresistor is less than 200, the LED will be on, otherwise, it will be off.

Img

12. Write the Program

① Find the instruction blocks

(1)Img

(2)Img

(3)Img

(4)Img

(5)Img

② Complete Program

Img

13. Test Result

Click Img to upload the complete program to the kidsuno mainboard and power up, then use your hands to cover the photoresistor . When the light intensity value read by the photoresistor is less than 200, the LED will be on, otherwise, it will be off.

Img

14. Extended Project

Img

The sample code is below:

Img