Micropython on RaspberryPi Pico W Question #11496
Unanswered
bfpa40
asked this question in
RP2040 / Pico
Replies: 2 comments 1 reply
-
It's hard to tell what's wrong if the indentation is lost. You have to enclose code in lines with three backticks ``` to display it right.
It will never leave the loop, because you do not update the value of input in the loop. Instead,. it must read something like:
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I am trying to post my code with this post, below is the code:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm Using Micropython in Thonny. I have made a script that has my RaspberryPi Pico when powered up set GPIO Pin 13 as an Output then Set GPIO Pin 4 and an Input and then set GPIO Pin 13 high. I now want it to monitor GPIO Pin 14 for an input (High). When receiving the Input High on GPIO Pin14 it will finish the script and start a 10 minute countdown and then set GPIO Pin 13 Low. I think..."think" I have it mostly resolved except for the monitoring pin 14 for the high. I have a while statement calling out monitoring pin 14 with a break statement but not having any luck getting it working correctly. To Trigger pin 14 I have been jumpering pin 36 (3.3vdc) to pin 19 (gpio 14) manually with a jumper wire and i cannot get it to break from the while statement. I have attached the code i have thus far below the line. Again I am using Micropython on a RaspberryPi Pico W. In the shell window on thonny im seeing a "repeating Value is 0" even when jumpering the pin36 to pin 19. can anyone offer assistance?
Thank You! -Brian-
#New Script written in Micropython for Pi Pico
#Using RaspberryPi Pico Interpreter and Micropython MicroPython v1.20.0 on 2023-04-26
import machine
from machine import Pin
import utime
from machine import Timer
#Used for the OnBoard LED of the pico
led = machine.Pin("LED", machine.Pin.OUT)
led.off()
led.on()
#Create output for Pin 13
p13 = Pin(13, Pin.OUT)
#Create input for Pin 4
p14 = Pin(14, Pin.IN, Pin.PULL_DOWN)
#Set Pin 13 Value High Initially
Pin(13, mode=Pin.OUT)
p13.value(1)
print("Pin 13 now set high")
#Set Pin 4 Value Low Initially
p14.value(0)
print("Pin 13 is set to:")
print(p13.value())
print()
#To read Pin 13 Value type print(p13.value())
#(Section is for reading Input High on Pin 4)
input = (p14.value())
print("Input Value to Pin 14 is:")
print(input)
print()
while input == 0:
print("Value is 0")
check2 = (p14.value())
if check2 == 1:
print("HIGH")
break
x = 0
for y in range(0, 12):
utime.sleep(1)
x += 1
print(x)
led.toggle()
print()
p13.value(0)
print("Pin 13 is now set Low")
print("Pin 13 is set to:")
print(p13.value())
led.on()
utime.sleep(2)
led.off()`
Beta Was this translation helpful? Give feedback.
All reactions