I've felt so sorry for all the people who want to follow along with these tutorials but who can't source/afford a Pi 3/4/400. As Picos are cheap and readily available, I wondered if it would be possible to use one instead. And, yes, it is!! So far... I've put the code in the description for each video and I've created a playlist (with some lame blurb that probably wouldn't help anyone) on my channel in case anyone is interested. This is the link for the playlist: ua-cam.com/play/PLWJsuyqCiVXOlL2FMW89ASuS-4BdNNDTj.html
Thanks for going through this, Charlotte. Will you please show your code as well? I'm somewhat interested in the Pico, and would love to see how you're accomplishing this.
That is a great idea, particularly as you succeeded in making it work. I bought a Pico about a year ago and had trouble with its onboard memory. I'm sure that's because I misunderstood the directions.
Pico has more in common with Arduino nano than RPi4. I program my unos and Pico's USING my RPi4. Gpio is different, the RPI 4 has the ability to do a headless VNC/ssh boot (when I don't have a head to display to I can boot my RPI for and then connect via VNC from my Android phone and control the desktop GUI or the command line interface), micropython (pico/Arduino) is not the same as Python 3 or c/c++, etc.... There's a lot of differences between them
@@Wythaneye All my code is in the comments on the videos. I'm not as clever as most of the people doing these lessons but trying to do things on the Pico gave me the incentive to actually take it out of its bag for the first time. Next thing is my soldering iron but that is REALLY scary!
A little late to the party, but: I am UBER legend. The trick was realizing I had to test the button state and see if it had been released between the last iteration and this one. Paul's big clue was to hold the button down and show us that the LED's state changed upon releasing the button, not upon pressing it. Fun project!
Paul have you tackled using one button for two functions somewhere? (Short press / long press) It would be grand if you could help with this!! Many thanks
Paul, I was a little confused by the 'not LEDState' line. I understand how it works and the function of the 'if' statements you proposed could replace it. We define LEDState as a variable up top but we could have as easily assigned it a number like 8 or 514. How does that operation know that we are thinking of LEDState as specifically as a 1 or 'not a one' -ie 0?
Hi, I used counter method, as if it was devidable by 2, it would turn on and if no turn off, this way, I could make it blink by holding the button too.
Hi, managed to solve this slightly differently, one problem I had to solve was not knowing the not function, I tried to do what Paul said (if LEDstate==0: LEDstate=1 “Do somthing” If LEDstate==1: LEDstate=0 “Do somthing else”) But doing that will always end up with LEDstate as 0 (as the first if sees a state of 0 so makes it 1, the second then sees the 1 and makes it a 0 again) Using an else instead of a second if was my solution, and of course there is Paul’s. Just thought I’d post in case anyone was having similar issues and couldn’t work out why it didn’t work :)
Thanks for another great video. I do 1-2 of your lessons each night. I have a piJuice Hat on my RPi 4. Have you seen those? They are cool, battery HAT with a solar controller for panels. Works really well on standard pi linux distribution. Thought with your prepper interest I would mention it encase you had not seen it.
Hi. I really like your video. They're super helpful. I learned arduino uno with your videos. I really appreciate all the efforts you're putting in. I've got a favor to ask. Have you got any plans for teaching us a bit about arm programming? Specificly Stm series which are used almost everywhere. Or at least could you help us to get started? I don't know where to start. Thank a lot
Hey paul..can you please help me in my project.?..i need a arduino code to drive Hub BLDC motor using joystick to go forward backward left and right ,using stp75nf75 igbt and ir2103 IC as the driver circuit.please help
Not directly. You should only draw 3 milli amps per output pin, but many sources say a maximum of 16 ma per pin. The maximum total current draw for all pins used is 50 ma. You can use an output to drive a transistor or a relay (or one of several devices) to increase your output current, but use a different power source than your Raspberry Pi to supply the current.
This is a really good video, but you got some extra views and re-views from me because I spent too long wondering what I did wrong, only to find out I didn't capitalize the State in buttonState. I will forever remember that States are supposed to be capitalized. 😀
hey Guys, I'm a real noob here. Didn't manage to do the homework, as I'm still wrapping my head around Python. I copied Paul's code, but I don't get the link between the setup line (buttonStateOld=1) and the 2nd part of the if line (...and buttonStateOld==0: If we recorded for the program the status as 1, how would it know that when the button was pressed the buttonOldState was 0, especially that 3 lines later we tell it that the buttonStateOld needs to be 1 (buttonStateOld=buttonState), as the code keep running dry before we actually press anything?
The way I did this in the "New Arduino tutorials" is how I did this assignment here. The key part of this code is to use an if statement that is "watching" for the button to be pressed followed directly by a while loop that continues so long as the button is held down: if tog0V == 0: while tog0V == 0: tog0V = GPIO.input(tog0) 1. At the start of the program, tog0V (my variable for the pushbutton voltage value) equals 1, so the program skips the if statement and the code under it. Nothing changes. 2. After the button is pressed, tog0V == 0, so the program "enters" the if-statement. 3. Directly following the if-statement, their is the while loop that continues so long as tog0V ==0. Since the button was pressed down, tog0V is at 0. It will remain at 0 until it is released where it switches to one and exits the while-loop. 4. Upon exiting the while-loop, the program runs through a set of if/elif statements that turn the LED on or off and reset the LED state. This reduces the number of variables as you do not need to assign a old and new toggle value. You can just use one variable.
@@paulmcwhorter I think I had this idea from your lesson in Arduino about using the serial port; when Serial.Available(), "do nothing". This method is not very easy to use when using more than one button (like in the next lesson), as the while loop freezes the code if you hold down a button.
Got it working :). This was my solution: import RPi.GPIO as GPIO inPin = 40 outPin = 38 powerOn = True released = True GPIO.setmode(GPIO.BOARD) GPIO.setup(inPin,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(outPin,GPIO.OUT) try: while True: readVal = GPIO.input(inPin) if readVal == 1: released = True if readVal == 0: if powerOn == True and released == True: powerOn = False released = False GPIO.output(outPin,0) if powerOn == False and released == True: powerOn = True released = False GPIO.output(outPin,1) except KeyboardInterrupt: GPIO.cleanup() print("GPIO Ready to Go")
I went to this video and saw that you used two variable instead of three. Easier for me to understand (the old way). Why use three variables this time? ua-cam.com/video/9X5z2lxe8Vs/v-deo.html
Definitely had fun with this one. Setting the min and max window isn't the same as c/c++/Arduino. I used : integer = max(0, min(integer, 100)) to limit the duty cycle value to 0.0-100.0. if you don't then the program gets finicky with pwm.ChangeDutyCycle(value) ua-cam.com/video/CMk9q_fk9bw/v-deo.html Edit: just realized I shared this on lesson 8 and not 9 🤦 🤣
Thank you Mr. Paul; As you are really connected to the source, your teaching is powerful as usual;
I've felt so sorry for all the people who want to follow along with these tutorials but who can't source/afford a Pi 3/4/400.
As Picos are cheap and readily available, I wondered if it would be possible to use one instead. And, yes, it is!! So far...
I've put the code in the description for each video and I've created a playlist (with some lame blurb that probably wouldn't help anyone) on my channel in case anyone is interested.
This is the link for the playlist: ua-cam.com/play/PLWJsuyqCiVXOlL2FMW89ASuS-4BdNNDTj.html
Thanks for going through this, Charlotte. Will you please show your code as well? I'm somewhat interested in the Pico, and would love to see how you're accomplishing this.
GPIO pins ore different, no WiFi and Micro Python isn't 100% the same as python 3.
That is a great idea, particularly as you succeeded in making it work. I bought a Pico about a year ago and had trouble with its onboard memory. I'm sure that's because I misunderstood the directions.
Pico has more in common with Arduino nano than RPi4. I program my unos and Pico's USING my RPi4. Gpio is different, the RPI 4 has the ability to do a headless VNC/ssh boot (when I don't have a head to display to I can boot my RPI for and then connect via VNC from my Android phone and control the desktop GUI or the command line interface), micropython (pico/Arduino) is not the same as Python 3 or c/c++, etc.... There's a lot of differences between them
@@Wythaneye All my code is in the comments on the videos. I'm not as clever as most of the people doing these lessons but trying to do things on the Pico gave me the incentive to actually take it out of its bag for the first time. Next thing is my soldering iron but that is REALLY scary!
I love the way Mr. McWhorter explains everything! I really wish someday He teaches Raspberry Pi Pico with Micropython!! :)
I am Uber LEGEND - Many thanks for this lesson. I did the homework after Lesson 7, using Nested If Statements, and it went fine.
A little late to the party, but: I am UBER legend. The trick was realizing I had to test the button state and see if it had been released between the last iteration and this one. Paul's big clue was to hold the button down and show us that the LED's state changed upon releasing the button, not upon pressing it. Fun project!
Hey Paul, your course is amazing. Im sending my solution below:
from time import sleep
import RPi.GPIO as GPIO
delay = 0.1
inPin = 40
outPin = 38
currentState = 0
GPIO.setmode(GPIO.BOARD)
GPIO.setup(outPin, GPIO.OUT)
GPIO.setup(inPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
try:
GPIO.output(outPin, currentState)
while True:
if GPIO.input(inPin) == 0:
currentState += 1
GPIO.output(outPin, currentState % 2)
while GPIO.input(inPin) == 0:
sleep(delay)
sleep(delay)
except KeyboardInterrupt:
GPIO.cleanup()
print('Program has been interrupted')
Excellent lesson! Thanks for the great content.
My pleasure!
Paul have you tackled using one button for two functions somewhere? (Short press / long press) It would be grand if you could help with this!! Many thanks
Takk!
Thanks! Really appreciate it!
Hey Paul! Do consider teaching us ROS programming for the next series. That would be sweet!
Paul,
I was a little confused by the 'not LEDState' line. I understand how it works and the function of the 'if' statements you proposed could replace it. We define LEDState as a variable up top but we could have as easily assigned it a number like 8 or 514. How does that operation know that we are thinking of LEDState as specifically as a 1 or 'not a one' -ie 0?
Hi, I used counter method, as if it was devidable by 2, it would turn on and if no turn off, this way, I could make it blink by holding the button too.
Paul,
Enjoyed the lesson. Thank you.
Question: can the pull up or down resistor be put in the LED circuit as well?
Thanks
Fred
Outstanding lesson
Hi, managed to solve this slightly differently, one problem I had to solve was not knowing the not function, I tried to do what Paul said
(if LEDstate==0:
LEDstate=1
“Do somthing”
If LEDstate==1:
LEDstate=0
“Do somthing else”)
But doing that will always end up with LEDstate as 0 (as the first if sees a state of 0 so makes it 1, the second then sees the 1 and makes it a 0 again)
Using an else instead of a second if was my solution, and of course there is Paul’s.
Just thought I’d post in case anyone was having similar issues and couldn’t work out why it didn’t work :)
Thanks for another great video. I do 1-2 of your lessons each night. I have a piJuice Hat on my RPi 4. Have you seen those? They are cool, battery HAT with a solar controller for panels. Works really well on standard pi linux distribution. Thought with your prepper interest I would mention it encase you had not seen it.
May I know does the button has specific name?
Hi. I really like your video. They're super helpful. I learned arduino uno with your videos. I really appreciate all the efforts you're putting in.
I've got a favor to ask. Have you got any plans for teaching us a bit about arm programming? Specificly Stm series which are used almost everywhere. Or at least could you help us to get started? I don't know where to start.
Thank a lot
Pro tip: use a needle or pin to re-open the hole for the strip that contains the resistors, It will slide in easy,
Hey paul..can you please help me in my project.?..i need a arduino code to drive Hub BLDC motor using joystick to go forward backward left and right ,using stp75nf75 igbt and ir2103 IC as the driver circuit.please help
could you add a 3.3 volt, 1watt, 350 milli amp, led bead light (100 Lumen) to your Raspberry Pi?
Not directly. You should only draw 3 milli amps per output pin, but many sources say a maximum of 16 ma per pin. The maximum total current draw for all pins used is 50 ma. You can use an output to drive a transistor or a relay (or one of several devices) to increase your output current, but use a different power source than your Raspberry Pi to supply the current.
Theoretically yes, but the proper way would be through a power transistor or mosfet having the base or gate switched by the gpio of the RPI4
This is a really good video, but you got some extra views and re-views from me because I spent too long wondering what I did wrong, only to find out I didn't capitalize the State in buttonState. I will forever remember that States are supposed to be capitalized. 😀
hey Guys, I'm a real noob here. Didn't manage to do the homework, as I'm still wrapping my head around Python. I copied Paul's code, but I don't get the link between the setup line (buttonStateOld=1) and the 2nd part of the if line (...and buttonStateOld==0:
If we recorded for the program the status as 1, how would it know that when the button was pressed the buttonOldState was 0, especially that 3 lines later we tell it that the buttonStateOld needs to be 1 (buttonStateOld=buttonState), as the code keep running dry before we actually press anything?
i`m using a pull down resistor on the switch just in case. Might be 10k ohms.
great script thanks !!
2:13 I made it. No googling, nothing.
I AM UBER LEGEND
#UBERLEGEND
I folded like a cheap lawn chair.
21:27 The ant marches through the LED and makes a run for the kill switch
i dont get how buttonState goes to buttonStateOld. thats where i get confused.
everything makes sense except for the programming to me.
The way I did this in the "New Arduino tutorials" is how I did this assignment here. The key part of this code is to use an if statement that is "watching" for the button to be pressed followed directly by a while loop that continues so long as the button is held down:
if tog0V == 0:
while tog0V == 0:
tog0V = GPIO.input(tog0)
1. At the start of the program, tog0V (my variable for the pushbutton voltage value) equals 1, so the program skips the if statement and the code under it. Nothing changes.
2. After the button is pressed, tog0V == 0, so the program "enters" the if-statement.
3. Directly following the if-statement, their is the while loop that continues so long as tog0V ==0. Since the button was pressed down, tog0V is at 0. It will remain at 0 until it is released where it switches to one and exits the while-loop.
4. Upon exiting the while-loop, the program runs through a set of if/elif statements that turn the LED on or off and reset the LED state.
This reduces the number of variables as you do not need to assign a old and new toggle value. You can just use one variable.
Nice approach
@@paulmcwhorter I think I had this idea from your lesson in Arduino about using the serial port; when Serial.Available(), "do nothing".
This method is not very easy to use when using more than one button (like in the next lesson), as the while loop freezes the code if you hold down a button.
I did it. I am successful
Got it working :). This was my solution:
import RPi.GPIO as GPIO
inPin = 40
outPin = 38
powerOn = True
released = True
GPIO.setmode(GPIO.BOARD)
GPIO.setup(inPin,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(outPin,GPIO.OUT)
try:
while True:
readVal = GPIO.input(inPin)
if readVal == 1:
released = True
if readVal == 0:
if powerOn == True and released == True:
powerOn = False
released = False
GPIO.output(outPin,0)
if powerOn == False and released == True:
powerOn = True
released = False
GPIO.output(outPin,1)
except KeyboardInterrupt:
GPIO.cleanup()
print("GPIO Ready to Go")
I want to see a solution to the opposite! A toggle switch that operates like a button.
I am uber legend!!!!!!!!!!!
LEGEND!
I am uber legend.
I will not be able to join because I have a license test.
What kind of License?
@@paulmcwhorter 😂 Drivers. Sorry
yes solved 16 lines
I'm an uber legend
You could have used if else. Then using NOT
I folded like a cheap walmart lawnchair, though not for lack of trying.
I am Uber Legend!
LEGEND!
I went to this video and saw that you used two variable instead of three. Easier for me to understand (the old way). Why use three variables this time? ua-cam.com/video/9X5z2lxe8Vs/v-deo.html
I am an Uber Walmart lawn chair.
i am a cheap walmart lawn chair
import RPi.GPIO as GPIO
import time
led_pin = 4
input_pin = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)
GPIO.setup(input_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
is_on = False
input = True
try:
while True:
time.sleep(0.1)
if input == GPIO.input(input_pin):
continue
if GPIO.input(input_pin) == GPIO.HIGH:
is_on = not is_on
GPIO.output(led_pin, is_on)
input = not input
except KeyboardInterrupt:
GPIO.output(led_pin, GPIO.LOW)
GPIO.cleanup()
folded up like a cheap walmart lawn chair
Keep trying! Watch my solution.
😂
I am UberLegend
LEGEND!
I AM UBER LEGEND
LEGEND!
Definitely had fun with this one. Setting the min and max window isn't the same as c/c++/Arduino.
I used : integer = max(0, min(integer, 100)) to limit the duty cycle value to 0.0-100.0. if you don't then the program gets finicky with pwm.ChangeDutyCycle(value)
ua-cam.com/video/CMk9q_fk9bw/v-deo.html
Edit: just realized I shared this on lesson 8 and not 9 🤦 🤣
Most Excellent!