Dc Motor Hat

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
Halover9k
 
Posts: 2
Joined: Fri Feb 16, 2018 10:21 pm

Dc Motor Hat

Post by Halover9k »

Hello, first post. I am making a small little bot to fill idle time. I have everything up and running EXCEPT whenever i use the keyboard interrupt or end the script any other way the atexit.register(turnoffMotor) with the required function to release all the motors, nothing stops. the motors keep on going. nothing stops till i completely reset the pi.
any suggestions?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Dc Motor Hat

Post by adafruit_support_mike »

You'll need to create a signal handler.

Signals are messages the kernel sends to a program while it's running. They're kind of like interrupts in the microcontroller world, but they're generated by software instead of a rising or falling edge on an IO pin. Signal handlers are functions that run when when the program receives a given signal.

Python has its own set of rules and conventions for handling shutdown signals. Here are links to the library reference and an example of how to write the code:

https://docs.python.org/2/library/signal.html
https://www.g-loaded.eu/2016/11/24/how- ... g-signals/

User avatar
Halover9k
 
Posts: 2
Joined: Fri Feb 16, 2018 10:21 pm

Re: Dc Motor Hat

Post by Halover9k »

Many thanks the the quick reply! i had no clue, your awesome!

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”