setup()
Initialize servos
configure pins
Include
Servo library
Constants
IOpins
define
global variables
and servos
Yes
No
Follow()
Play()
Jump()
Walking
Motion()
Sitting
Motion()
Is puppy
bored?
IReye()
IRtrack()
Look
up?
Take
step?
Do
nothing
SitShake
Liedown()
Puppy
sitting?
No
Yes
Shake
Right
Shake
Left
Lie
down
Get
up
loop()
On / Reset
14
Understanding the Code:
Although you can play with the robot using just the sample code provided, the real fun is in teaching it new tricks!
This section explains some of the basic features of the code and how they can be changed. Do not be afraid to
experiment, you can always restore the original code if you make a mistake.
Below is a flowchart of the sample code. A flow chart is not actual code, it is more like a map showing blocks of code
and the different paths the processor can follow within your code. Lines linking the blocks have an arrow head
showing the direction that the processor must follow along the path.
As you can see, once the processor enters the loop(), no matter which path it takes, they all return back to the loop
and the process is repeated. The only way to break out of the loop is to switch the power off or reset the processor.
Depending on the inputs from the sensors and the values of the timers, different paths are taken
as the code repeats the loop over and over again. If you write additional code to teach the puppy
new tricks then additional pathways will be added to the map.