Reader small image

You're reading from  MicroPython Cookbook

Product typeBook
Published inMay 2019
Reading LevelBeginner
PublisherPackt
ISBN-139781838649951
Edition1st Edition
Languages
Right arrow
Author (1)
Marwan Alsabbagh
Marwan Alsabbagh
author image
Marwan Alsabbagh

Marwan Alsabbagh has been coding in some form or other since before the web existed and has continued to develop software, with a particular passion for Python, his preferred programming language, for over a decade. He has been a speaker at a number of global Python conferences, where he has been known to present microcontroller projects with a healthy dose of humor and stage theatrics. The snow globe intruder alert system, which he created with his creative and curious daughters, was one of his favorite MicroPython projects. His research interests include software engineering, microcontrollers, and 3D printing.
Read more about Marwan Alsabbagh

Right arrow

Controlling a DC motor with buttons

In this recipe, we will use push buttons to increase and decrease the speed of the DC motor. We can use the same script to change the direction of rotation with the push buttons. Essentially, one push button will make the motor increase speed in one direction, and the other push button will make the motor move more in the other direction. In this way, we can use the pair of push buttons to set a range of speeds in either direction and to bring the motor to a full stop.

As the script is run, the current speed and direction will be printed to the screen. This recipe can be useful in any project in which you want to have user input translated into motion. You could, for example, create a project in which you attach a pulley to a DC motor and use the push buttons to raise and lower the pulley.

...
lock icon
The rest of the page is locked
Previous PageNext Chapter
You have been reading a chapter from
MicroPython Cookbook
Published in: May 2019Publisher: PacktISBN-13: 9781838649951

Author (1)

author image
Marwan Alsabbagh

Marwan Alsabbagh has been coding in some form or other since before the web existed and has continued to develop software, with a particular passion for Python, his preferred programming language, for over a decade. He has been a speaker at a number of global Python conferences, where he has been known to present microcontroller projects with a healthy dose of humor and stage theatrics. The snow globe intruder alert system, which he created with his creative and curious daughters, was one of his favorite MicroPython projects. His research interests include software engineering, microcontrollers, and 3D printing.
Read more about Marwan Alsabbagh