
Piarm, Release 1.0
4.4.1 Shovel Bucket - Joystick Control
cd
/
home
/
pi
/
piarm
/
examples
sudo python3 joystick_module1
.
py
Once the code is run, you will be able to control the rotation of PiArm’s arm by toggling the left and right joysticks,
and controlling the angle of the Shovel Bucket by pressing the left and right joysticks respectively.
But you need to assemble
to PiArm first.
Code
from
robot_hat
import
Servo,PWM,Joystick,ADC,Pin
from
robot_hat.utils
import
reset_mcu
from
time
import
sleep
from
piarm
import
PiArm
reset_mcu()
sleep(
0.01
)
leftJoystick
=
Joystick(ADC(
'A0'
),ADC(
'A1'
),Pin(
'D0'
))
rightJoystick
=
Joystick(ADC(
'A2'
),ADC(
'A3'
),Pin(
'D1'
))
arm
=
PiArm([
1
,
2
,
3
])
arm
.
bucket_init(PWM(
'P3'
))
arm
.
set_offset([
0
,
0
,
0
])
(continues on next page)
4.4. Dual Joystick Module Control
115
Summary of Contents for PiArm
Page 1: ...Piarm Release 1 0 www sunfounder com Mar 31 2022 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...Piarm Release 1 0 2 CONTENTS ...
Page 8: ...Piarm Release 1 0 4 Chapter 1 Component List and Assembly Instructions ...
Page 48: ...Piarm Release 1 0 44 Chapter 3 Play with Ezblock ...
Page 91: ...Piarm Release 1 0 3 9 GAME Iron Collection 87 ...
Page 92: ...Piarm Release 1 0 88 Chapter 3 Play with Ezblock ...
Page 99: ...Piarm Release 1 0 Step 7 Click the WRITE button 4 1 Quick Guide on Python 95 ...
Page 148: ...Piarm Release 1 0 Yes then Ok Finish 144 Chapter 5 Appendix ...
Page 152: ...Piarm Release 1 0 Step 4 Double click the connection just created 148 Chapter 5 Appendix ...
Page 160: ...Piarm Release 1 0 156 Chapter 5 Appendix ...