Welcome to Building:bit Superkit repository
3.4 Photosensitive robot
Photosensitive robot
Photosensitive robot1. Learning objectives2. Building blocks3. Sensor wiring4. Programming4.1 Add expansion package4.2 Building blocks used4.3 Combining blocks5. Experimental phenomenon
1. Learning objectives
In this course, we mainly learn how to realize light-controlled robots through MakeCode graphical programming.
2. Building blocks
For the building blocks steps, please refer to the installation drawings of [Assembly Course]--[Light-controlled bipedal robot] in the materials or the building blocks installation book.
3. Sensor wiring
Insert the motor wiring on the left side of the car into the M1 interface of the Super:bit expansion board, with the black wire close to the battery side;
The photosensitive module is connected to the P1P2 interface.

4. Programming
Method 1 Online programming:
First, connect the micro:bit to the computer via a USB data cable. The computer will pop up a U disk. Click the URL in the U disk: https://makecode.microbit.org/ to enter the programming interface. Then, add the Yahboom software package https://github.com/YahboomTechnology/SuperBitLibV2, and you can start programming.
Method 2 Offline programming:
Open the offline programming software MakeCode and enter the programming interface. Click [New] and add the Yahboom software package https://github.com/YahboomTechnology/SuperBitLibV2 to start programming.
4.1 Add expansion package


4.2 Building blocks used
The location of the building blocks required for this programming is shown in the figure below.




4.3 Combining blocks
The summary program is shown in the figure below.

You can also directly open the Photosensitive-robot.hex file provided in this experiment and drag it into the browser that opens the URL, and the program diagram of this project source code will be automatically opened.
Since the photosensitive module is affected by the ambient light, the obtained values will also be different. Please modify the sensor threshold according to your actual situation.
5. Experimental phenomenon
After the program runs successfully, if the photosensitive module detects light, the motor will drive the bipedal man to walk. If you cover the photosensitive module with your hand, the bipedal man will stop walking.