Skip to Content
Learn Robotics Programming
book

Learn Robotics Programming

by Danny Staple
November 2018
Beginner
472 pages
13h 5m
English
Packt Publishing
Content preview from Learn Robotics Programming

Simple counting

This code will count the number of cycles up and down on the signal pin for each wheel, and print them as we go to test the sensors. We will run our motors for about 1 second.

Let's start with the usual robot class import and time:

from robot import Robotimport time...

Next, we'll add an import for a GPIOZero input device. We can use the pin it sets up to count our pulses:

...from gpiozero import DigitalInputDevice...

The encoders generate pulses; we will want to count them and track their state. We will use more than ...

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

Learn Robotics Programming - Second Edition

Learn Robotics Programming - Second Edition

Danny Staple

Publisher Resources

ISBN: 9781789340747Supplemental Content