Skip to Content
Raspberry Pi 3 Cookbook for Python Programmers - Third Edition
book

Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

by Steven Lawrence Fernandes, Tim Cox
April 2018
Beginner content levelBeginner
552 pages
13h 58m
English
Packt Publishing
Content preview from Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

How to do it...

  1. Create the following servo_control.py script:
#!/usr/bin/env python3 #servo_control.py import curses import os #HARDWARE SETUP # GPIO # 2[=VX==2=======]26[=======]40 # 1[===013=======]25[=======]39 # V=5V X=Gnd # Servo 0=Turn 1=Shoulder 2=Elbow 3=Claw name=["Turn","Shoulder","Elbow","Claw"] CAL=[90,90,90,90] MIN=[0,60,40,60]; MAX=[180,165,180,180] POS=list(CAL) KEY_CMD=[ord('c'),ord('x')] #Keys to rotate counter-clockwise KEY_LESS={ord('d'):0,ord('s'):1,ord('j'):2,ord('k'):3} #Keys to rotate clockwise KEY_MORE={ord('a'):0,ord('w'):1,ord('l'):2,ord('i'):3} STEP=5; LESS=-STEP; MORE=STEP #Define control steps DEG2MS=1.5/180.0; OFFSET=1 #mseconds IDLE=2000 #Timeout servo after command SERVOD="/home/pi/PiBits-mater/ServoBlaster/user/servod" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Raspberry Pi for Python Programmers Cookbook - Second Edition

Raspberry Pi for Python Programmers Cookbook - Second Edition

Tim Cox

Publisher Resources

ISBN: 9781788629874Supplemental Content