Understanding The Code - DAGU Playful Puppy Instruction Manual

Hide thumbs Also See for Playful Puppy:
Table of Contents

Advertisement

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.
Get
up
Shake
Shake
Right
Left
Lie
down
SitShake
Liedown()
Puppy
sitting?
Yes
No
Sitting
Motion()
Initialize servos
loop()
IReye()
IRtrack()
Is puppy
bored?
Yes
No
Follow()
Take
step?
Walking
Motion()
14
global variables
setup()
configure pins
Play()
Look
up?
Do
nothing
Jump()
On / Reset
Include
Servo library
Constants
IOpins
define
and servos

Advertisement

Table of Contents
loading

Table of Contents