A Kitten with Blinking Eyes and a Waving Tail

 

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.

1.jpg

 

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.

 

2.jpg

3.jpg

4.jpg

 

Stick the tail to the servo motor. Connect the body and tail of the kitten with Halocode, the servo motor, and the battery box.

5.jpg

6.jpg

7.jpg

 

Toggle on Upload mode

8.gif

 

Script of Blinking Eyes

1. Drag an Events block when Halocode starts up and a Control block forever to the Scripts area.

9.gif

 

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.

0.gif

 

Script of the Waving Tail

3. Drag an Events block when Halocode starts up and a Control block forever to the Scripts area.

01.gif

 

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.

02.gif

 

5. Add another Pins block servo pin () rotates to () and Control block wait () seconds. Both keep the default value.

03.gif

 

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?

04.gif

Download code


Was this article helpful?
3 out of 3 found this helpful

Comments

0 comments

Please sign in to leave a comment.