Outline
Let's make a turn signal: press the left switch, and the left light is turned on; press the right switch, and the right light is turned on.
Suitable kits: mCookie202, mCookie302, IBC
Module Bill
Module
Other Equipment
- USB cable*1
- Sensor cable*4
- Sensor shell*1
- Lego or other fixation structure
Module Setup
- Assemble modules and sensors:
- Stick the red core module, battery base, and green extension module together;
- Connect the 2 red LEDs to pin 6/7 and 8/9 of Hub respectively;
- Connect the 2 crash sensors to pin 2/3 and 4/5 of Hub respectively;
- Insert one end of USB cable into USB upload module, and connect the other to computer;
Programming
Required Program Blocks
Programming Thought
Use "if - do" condition statement to detect which is pressed between the two crash sensors on both sides, and make the corresponding LED flash, ad continue to detect after the LED ends flashing.
Start to Program
1. If the left switch is pressed, the left LED will flash once.
Take the switch of pin 2 as the left switch, and the LED of pin 6 as the left LED; put the flashing(on and off once) program into executed internal program: if the left switch is pressed, the left LED will flash once.
2. If the right switch is pressed, the right LED will flash once
Take the switch of pin 4 as the right switch, and the LED of pin 8 as the right LED; put the flashing program into the executed internal program: if the right switch is pressed, the right LED will flash once.
Test the result
After upload the program, press the left switch, and the left LED will flash; press the right switch, and the right LED will flash.
Technical Specification
Related Cases
FAQ
|