Comments (2)
Sorry for late reply.
The reset has nothing to do with the Pin state.
It occurs because the the watchdog resets the system after 6 seconds.
Every long running loop should have either the sleep_ms method with period longer tham 2 ms, or reset watchdog method inserted (or both).
import time, machine
from machine import Pin
p1 = Pin(18, Pin.IN, Pin.PULL_UP)
while True:
if not p1.value():
print('Button pressed!')
while not p1.value():
#time.sleep_ms(3)
machine.wdt_reset()
print('Button not pressed!')
#time.sleep_ms(3)
machine.wdt_reset()
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import time, machine
=== from machine import Pin
=== p1 = Pin(18, Pin.IN, Pin.PULL_UP)
=== while True:
=== if not p1.value():
=== print('Button pressed!')
=== while not p1.value():
=== #time.sleep_ms(3)
=== machine.wdt_reset()
=== print('Button not pressed!')
=== #time.sleep_ms(3)
=== machine.wdt_reset()
===
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Button pressed!
Button not pressed!
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
KeyboardInterrupt:
>>>
from micropython_k210_lobo.
thanks problem solved :)
from micropython_k210_lobo.
Related Issues (20)
- KPU HOT 8
- Using pre-built firmware with Maixduino HOT 2
- Local build firmware HOT 10
- FLASH File system initialization failed! SOLVED. HOT 15
- WiFi "Error setting baudrate" HOT 50
- When triangle is drawn with fill colour, firmware crashes and reboots
- BUILD.sh improvements on MacOS HOT 4
- Can't use SSL with latest firmware HOT 2
- machine.UART not working HOT 3
- using old microSD cards version 1 HOT 1
- cannot flash on maixpy go HOT 2
- TFT Display on Maix Amigo HOT 2
- Unexpected Restarts
- BUILD.sh script failing HOT 15
- I2C device already used / Error initializing I2C hardware HOT 8
- Read data from 16-bit register address (I2C) HOT 2
- WiFi firmware HOT 2
- Camera and LCD not working, OMV modules not part of this port HOT 1
- Cannot flash the WiFi firmware to M1W HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython_k210_lobo.