Тёмный

Learn MicroPython #4 - Interrupts (event-driven code) 

Invent Box Tutorials
Подписаться 28 тыс.
Просмотров 26 тыс.
50% 1

Full code available on Github!
github.com/invent-box/Learn-M...
In the last video, we made a program that would turn an LED on whenever a button is pressed. However, we found that as long as the program is running, the Python REPL console is blocked from starting. At the end of this video, we will have a program that does the same thing with the LED and button, but will also allow the REPL to start. This will be accomplished by using a feature of MicroPython called "interrupts" that allows us to build the program in an event-driven way. Hope you have fun with this one!
**************************************************
We use FREE open source software with the following machines:
(ALL open source software is free so YOU can try it too) **************************************************
LASER CUTTER ENGRAVER: amzn.to/2IjMAeK
extra features (red dot laser & wheels): amzn.to/3cmH341
air assist (for better cutting): amzn.to/38uIvjh
VINYL CUTTER: amzn.to/39AGYs8
WOOD LATHE: amzn.to/33oQVY1
tool set: amzn.to/2w7OWv0
caliper: amzn.to/3b3eisx
CNC ROUTER / MILLING MACHINE
cnc router: amzn.to/336ofTu
mini milling machine: amzn.to/34HTEwn
2 flute end mill set: amzn.to/2xlbj0b
MINI METAL LATHE: amzn.to/2SpLSm2
MICROPHONE/HEADSET FOR MAKING VIDEOS: amzn.to/2wvwUCY
(As an Amazon Associate I earn from qualifying purchases.)
**************************************************
FREE VIDEO DEMOS:
Laser Cutting TIPS & TRICKS
Vinyl Cutting TIPS & TRICKS
Wood Lathing TIPS & TRICKS
Milling / CNC Router TIPS & TRICKS
Metal Lathing TIPS & TRICKS
**************************************************
We have entire playlists on learning open source software so have fun learning! The solution is right around the corner... InventBoxTutorials.
Great tutorials. Free software. Open to the world.

Опубликовано:

 

6 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@capiberra4118
@capiberra4118 4 года назад
Thanks for this set of M/P tutorials, very useful stuff indeed. This one caught my eye initially but i have since been back and watched the whole set. Well presented, well paced, clearly explained. Well done, Thanks!
@bgable7707
@bgable7707 3 года назад
Nicely done, great simple example of IRQ's, ie Interrupt Request Queue, as I know them. Thanks for your work!
@josseman
@josseman 3 года назад
I just found out about your channel and I love it! Thank you so much
@davidmarks509
@davidmarks509 2 года назад
Igreat tutorial I am really looking forward started today with micropyton. TY
@annasarahkramerfazendeiro8030
@annasarahkramerfazendeiro8030 4 года назад
Thank you for this series, well explained! While this video shortly touches the possibility of having several interrupt pins, I still don't understand how to actually do this. I have 2 motors and 4 limit switches, so I want each motor to stop moving in a certain direction when it reaches the associated limit switch (movement controlled by a system of 3 relays per motor). Would I need 1 function and 4 irq objects? Or 2 functions? Is there any explanation or tutorial I could follow to understand this better? Thanks a lot!
@minecraftteddy99
@minecraftteddy99 5 лет назад
How do I do long press ? Maybe I want the LED to turn on when I click the button and when I hold the button the LED should turn off.
@IRBry
@IRBry Год назад
Interrupt Re Quest idk where you got query from
@ThalassTKynn
@ThalassTKynn 2 года назад
Hey thanks for the video. I found it while trying to troubleshoot my code. I followed your code, and have it just like yours is at 13:05, minus the sleep timer and with a print statement instead of the led output. Even though I have the handler set to IRQ_RISING it reacts for both rising and falling events. I thought it might be a debouncing issue but it still happens with a SPST switch instead of the tactile momentary switch. There is a debouncing issue still, but the it stops printing after about 5 times. But it does this for both states. I'm running the code on an old Huzzah ESP8266 breakout with micropython v1.17 I'm gonna keep looking but any advice would be appreciated! Thanks!
@ta77o
@ta77o 5 лет назад
good morning, I wanted to get the value of the pin that got the interruption. example: def callback (pin_irq): print (pin_irq) result: Pin (14) I need only the value 14 not "Pin (14)" how can I do it?
@Kasslim11
@Kasslim11 4 года назад
My guess is that Micropython has a scheduler. Which is how it can make the interrupts' event handlers queue behind each other. The way interrupts work on machine level is much more complicated with priorities etc. Is my guess correct?
@freddymac128
@freddymac128 3 года назад
Can you make a video on using ESP-CAM with Micropython?!
@Huynh-Tan-Quoc
@Huynh-Tan-Quoc 4 года назад
i have a M5stack board. so, i want to create a event for textbox or create eventhandl, how do you do?
@sergiomoranavarrete9426
@sergiomoranavarrete9426 3 года назад
Why my led stays On even when i release the btn. ?
@elliot1784
@elliot1784 4 года назад
im having an issue.. My code is identical to yours.. but before I run it I get this yellow warning error: "Unresolved attribute reference 'irq' for class 'Pin'" then when I run it.. I get an error:"TypeError: can't convert 'int' object to str implicitly" any help? thanks
@anthonyanderson2752
@anthonyanderson2752 4 года назад
Why doesn't this require a while loop?
@thepierced
@thepierced 5 лет назад
Hi and thanks for the video. I work with a ESP32 and I can't explain why when I press the button, it happen randomly like multiple presses. I tried to add a 10K resistor OR / AND use the Pin.IN.PULL_UP Pin() parameter. Do you have a idea please? Thanks!
@HHashi
@HHashi 4 года назад
I know your comment is 2 months old but just in case you still haven't solved this, it sounds like you need to look into "debouncing". The issue you're facing is caused by noise, i.e. when you press down on the button, the signal will fluctuate up and down until it settles. Debouncing is a way to deal with this.
@thepierced
@thepierced 4 года назад
Thanks I agree with you, I will try to play with a debounce timer.
@GmanBB
@GmanBB 4 года назад
no irq function...
@mrem8804
@mrem8804 5 лет назад
It's possible to use threadding with MycroPython? To listen interrupts and execute at the same time. Thanks...
@inventboxtutorials1898
@inventboxtutorials1898 5 лет назад
Yes and no. Threading is only supported on some MicroPython ports at the moment. In their own documentation about the _thread module, they say: "This module is highly experimental and its API is not yet fully settled and not yet described in this documentation." I think the ESP32 port supports threading. Feel free to play with it. If you find that the threading is not working, you can use timers as an alternative to jumping between two tasks.
@ec92009y
@ec92009y 3 года назад
Nice but almost unwatchable. You have a very annoying fan running through the whole video.
Далее
Learn MicroPython #5 - Measuring sensor voltages (ADC)
14:14
Using MicroPython in the wild
31:55
Просмотров 35 тыс.
Это iPhone 16
00:52
Просмотров 924 тыс.
Using PICO Interrupts
25:15
Просмотров 18 тыс.
Python 101: Learn the 5 Must-Know Concepts
20:00
Просмотров 1,1 млн
JPEG is Dying - And that's a bad thing
8:09
Просмотров 69 тыс.
Learn MicroPython #6 - fade an LED with PWM
12:28
Просмотров 9 тыс.
Github - You Can View Deleted Private Fork Data
23:40
MicroPython #4 - PWM, ADC, Timers & Interrupts
13:52
Просмотров 36 тыс.
Это iPhone 16
00:52
Просмотров 924 тыс.