Tools and materials:
Make a kitten
Draw the kitten's body and tail on the cardboard, and then cut them out. Use the puncher to make two holes as the eyes of kitten.
Note: the distance of the two eyes should equal to the greatest distance between two LEDs of Halocode.
Connect the servo motor to Halocode (any of the four pins will work), as follows:
- The red line of the servo means the positive pole, and is connected to the red line of the alligator clip, which is connected to the 3.3v pin of Halocode.
- The black line of the servo means the negative pole, and is connected to the blue line of the alligator clip, which is connected to the GND pin of Halocode.
- The white line of the servo is the communication line, and is connected to the yellow line of the alligator clip, which can be connected to any touchpad of Halocode. We'll use touchpad0 in this example.
Stick the tail to the servo motor. Connect the body and tail of the kitten with Halocode, the servo motor, and the battery box.
Toggle on Upload mode
Script of Blinking Eyes
1. Drag an Events block when Halocode starts up and a Control block forever to the Scripts area.
2. Add a Lighting block all the LEDs light up () and a Control block wait () seconds. Set the color to white. We want the kitten to blink eyes randomly, so we need an Operators block pick random () to (), and input number 2 and 6. Add a Lighting block light off all the LEDs and another Control block wait () seconds. Set the time to 0.2 second.
Script of the Waving Tail
3. Drag an Events block when Halocode starts up and a Control block forever to the Scripts area.
4. Add a Pins block servo pin () rotates to () and a Control block wait () seconds. Set the degree to 0 and keep the default time.
5. Add another Pins block servo pin () rotates to () and Control block wait () seconds. Both keep the default value.
6. Click "Upload" to upload the program to Halocode.
7. Check the kitten! Is it blinking eyes and waving its tail at the same time?
Comments
Please sign in to leave a comment.