SunFounder PiDog Kit, Release 1.0
(continued from previous page)
my_dog
.
do_action(
'wag_tail'
, step_count
=
20
, speed
=
100
)
my_dog
.
speak(
'woohoo'
)
delay(
1
)
def
stand
():
my_dog
.
rgb_strip
.
set_mode(
'breath'
, front_color
=
'green'
, delay
=
0.02
)
my_dog
.
do_action(
'stand'
, wait
=
True
, speed
=
60
)
def
be_picked_up
():
isUp
=
False
upflag
=
False
downflag
=
False
my_dog
.
rgb_strip
.
set_mode(
'breath'
, front_color
=
'green'
, delay
=
0.02
)
stand()
while
True
:
ax
=
my_dog
.
accData[
0
]
(
'ax:
%s
, is up:
%s
'
%
(ax, isUp))
# gravity : 1G = 16384
if
ax
< -
16000
:
my_dog
.
body_stop()
if
upflag
==
False
:
upflag
=
True
if
downflag
==
True
:
isUp
=
False
downflag
=
False
stand()
if
ax
> -
13000
:
my_dog
.
body_stop()
if
upflag
==
True
:
isUp
=
True
upflag
=
False
fly()
if
downflag
==
False
:
downflag
=
True
sleep(
0.2
)
if
__name__
==
"__main__"
:
try
:
be_picked_up()
except
KeyboardInterrupt
:
my_dog
.
close()
2.2. Funny Project
57
Summary of Contents for PiDog
Page 1: ...SunFounder PiDog Kit Release 1 0 sunfounder Jan 09 2023 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder PiDog Kit Release 1 0 Content 2 CONTENTS ...
Page 8: ...SunFounder PiDog Kit Release 1 0 4 Chapter 1 Component List and Assembly Instructions ...
Page 15: ...SunFounder PiDog Kit Release 1 0 Step 7 Click the WRITE button 2 1 Quick Guide on Python 11 ...
Page 92: ...SunFounder PiDog Kit Release 1 0 88 Chapter 2 Play with Python ...
Page 108: ...SunFounder PiDog Kit Release 1 0 104 Chapter 4 Appendix ...