This course we will learn to control the exchange of two body lights up on the Tiny-bit microbit robot.
1.The position of the LED lights in the robot car, as shown below.
2. The micro:bit pins connected to the two LED lights.
From the hardware interface manual, we can know that two LED lights are directly driven by P12 of micro:bit.
from microbit import *
np = neopixel.NeoPixel(pin12, 2)
for pixel_id in range(0, len(np)):
np = (255, 0, 0)
np = (0, 255, 0)
Programming and downloading：
1.You should open the Mu software, and enter the code in the edit window, , as shown in Figure2-1.
Note! All English and symbols should be entered in English, and the last line must be a space.
2.As shown in Figure 2-2, you need to click the Check button to check if our code has an error. If a line appears with a cursor or an underscore, the program indicating this line is wrong.
3.You need to connect the micro data cable to micro:bit and the computer, then click the Flash button to download the program to micro:bit as shown in Figure 2-3.
4.After the download is successful, you can see that two LED lights will exchange to light red and green.
The code of the experiment: 2.LED light exchange lighting.zip
Micro python Robot Course：
- Micro python Robot Course 1: Light up a LED
- Micro python Robot Course 2: LED light exchange lighting
- Micro python Robot Course 3.Breathing light
- Micro python Robot Course 4: Whistle
- Micro python Robot Course 5: Play《Little Star》
- Micro python Robot Course 6: Sound sensor
- Micro python Robot Course 7: Black line control light
- Micro python Robot Course 8: Measuring worker