ESP8266 MicroPython - Tutorial 4: How To Interrupt Micropython
DFRobot
May 02 20171786
mode:Pin.IN input Pin.OUT output
value:output value
Pin.value ([value]) It means reading input level when it’s without parameter, and setting output level when it’s with parameter, which is 1/0. Pin.irq(*,trigger, handler=None)
Copy code "from machine import Pin[/align]value=1
counter=0
def func(v):
global value,counter
counter+=1
led.value(value)
if(value == 0):
value = 1
else:
value = 0
print("IRQ ",counter)
led = Pin(14, Pin.OUT)
led.value(0)
button = Pin(0, Pin.IN)
button.irq(trigger=Pin.IRQ_FALLING, handler=func)
while True:
pass" I don’t need the compiling environment of how to find port no. and how to enter esp8266 micropython. Refer to the previously published documents if you don’t understand. As shown below, after entering the compiling environment, paste our interrupt program according to the said method.
Press Ctrl+d to complete pasting and then run the program. Now it output <IRQ>, which means our program is good and is under execution. At this time, we can see that led light is in extinguished state on our esp8266 development board.
We connect a DuPont line to GPIO0 port of the board. Touch other pins with the other end of the DuPont line. There will be result as shown below. Every time of touch, led light will flash for one time, and counter number will increase. Therefore, we realize the effect of interruption.
Explore the performance of Small Language Models (SLMs) on the Raspberry Pi 5 SBC, including models like mathstral, phi 3, llama 3.1, gemma2 2b, and Qwen.
Explore our top picks for interactive sensors, DIY lighting, essential maker tools, and exciting project ideas to make this Halloween truly unforgettable!
This blog will provide an in-depth comparison of YOLOv10 and YOLOv8, analyzing their differences in model size, performance metrics, and hardware requirements.