In this experiment, we will apply both LED module and button module to form a lighting device.
Required:
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Completed!
Open KidsBlock and connect to the board, click File –> Load from your computer.
Choose D:\Code\1.Code_kidsuno to open 4.1Manual_lighting.sb3
Click to connect to port and then .
Code Blocks
Blocks |
Code block |
---|---|
Conceive:
Initialization
Set the pins of white LED module and button module, initialize the serial monitor.
Main Code
Loop: Determine whether the button is pressed. If it is, the button outputs 0. If not, the button outputs 1.
Press the button (pin reads value 0), and LED will light up (pin outputs high to LED module).
Release the button (pin reads value 1), and LED will go off (pin IO23 outputs low to LED module).
After uploading code, press the button, and LED lights up. When you release the button, LED is off.