DAGU Playful Puppy Instruction Manual page 19

Hide thumbs Also See for Playful Puppy:
Table of Contents

Advertisement

Understanding the code (cont.)
This robot uses some timers in the code to control certain functions. This is done using the millis() function which
counts the number of milliseconds since the robot was turned on. We will briefly look at how the unsigned long
variable sit is used to measure boredom in the robot.
In the [Play] tab, sit is set to equal the value reported by the millis() function whenever the robot takes a step. This
resets the boredom timer because the difference between millis() and sit is reset to 0.
In the loop() section of the code, the difference between millis() and sit are compared to the constant Boredom.
The result is that if the robot does not take a step for Boredom milliseconds then the robot will become bored and sit
down. Once this happens, the timer cannot be reset unless you make the robot look up at which point the variable sit
is set to equal the new value of millis() in the [SitShakeLiedown] part of the code and the difference is now 0 again.
In the loop() function, the program constantly reads the sensors in the eye, tracks movement with the head. If the
puppy is not bored then it will follow your hand and walk / jump in play mode. If the puppy becomes bored then it will
sit down. In this mode it will shake hands or lie down.
19

Advertisement

Table of Contents
loading

Related Products for DAGU Playful Puppy

Table of Contents