
Piarm, Release 1.0
• Press the
w
key on the keyboard, the
alpha
increases and the Arm will extend forward.
• Press the
s
key on the keyboard, the
alpha
decreases and the Arm will retract backward.
• Press the
a
key on the keyboard, the
gamma
increases and the Arm will turn left.
• Press the
d
key on the keyboard, the
gamma
decreases and the Arm will turn right.
• Press the
i
key on the keyboard, the
beta
increases and the Arm will raise up.
• Press the
k
key on the keyboard, the
beta
decreases and the Arm will lower down.
• Finally, use the
k
and
l
keys to control the opening and closing of the Hanging Clip respectively.
4.5.3 Electromagnet - Keyboard Control
Run the code
cd
/
home
/
pi
/
piarm
/
examples
sudo python3 keyboard_control1
.
py
After running the code, follow the prompts and press the keys on the keyboard to control the PiArm’s arms and
Electromagnet.
But you need to assemble
to PiArm first.
Note:
• To switch the keyboard to lowercase English input.
•
w
,
s
,
a
,
d
,
i
and
k
are used to control the rotation of the arm.
•
j
and
l
are used to control the ON and OFF of the Electromagnet.
Code
from
piarm
import
PiArm
from
robot_hat
import
Pin,PWM,Servo,ADC
from
time
import
time,sleep
from
robot_hat.utils
import
reset_mcu
import
sys
import
tty
import
termios
reset_mcu()
sleep(
0.01
)
arm
=
PiArm([
1
,
2
,
3
])
arm
.
electromagnet_init(PWM(
'P3'
))
arm
.
set_offset([
0
,
0
,
0
])
controllable
=
0
manual
=
'''
Press keys on keyboard
w: extend
s: retract
a: turn left
(continues on next page)
4.5. Keyboard Control
127
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 ...