Raspberry Pi LESSON 6 HOMEWORK SOLUTION: Understanding GPIO Inputs and Pull Up Resistors

  Рет қаралды 15,647

Paul McWhorter

Paul McWhorter

Күн бұрын

Пікірлер: 79
@foolofatook4925
@foolofatook4925 4 ай бұрын
Coming in hot in 2024. What a great homework assignment! I got everything right on the coding side, but as a person with next to zero hardware experience, I needed to learn the whole point of the lesson. I tried to create a single circuit instead of separate input and output circuits. This is far and away the best online course I’ve ever taken, and beats out many professors/teachers I’ve had in other subjects.
@paulmcwhorter
@paulmcwhorter 4 ай бұрын
Excellent!
@codecage9333
@codecage9333 Жыл бұрын
I am LEGEND! I wired my switch with a "pull-down" resistor, and I noticed your use of the "pull-up" resistor right off the bat was going to give you the opposite effect you desired using your initial code. And it was good to see you place the dropping resistor on the ground side of the LED as it really makes no difference in this circuit. And you never used the "delay" you defined. I know, picky, picky Pat Paulson!
@moeezyspanishletras
@moeezyspanishletras Жыл бұрын
I'm having trouble with the homework, but I'm learning every lesson. I'm definitely going to go back through and redo the assignments.
@captinkrazy6968
@captinkrazy6968 Жыл бұрын
Same here. its really hard to learn the code and rember it and how it works. building the circuits and stuff is the easy part for me.
@arguedas02
@arguedas02 2 жыл бұрын
Thanks for what you do, I really enjoy every single class you do.
@musicforlife4571
@musicforlife4571 Ай бұрын
I'm late to the party but loving your videos, thank you! I'm looking forward to the rest in the series. A note about the Except clause in your Python code. Although it is good practice to specify the exception type, in your case it's better to not specify so that in the case of ANY exception whatsoever, it runs a cleanup()
@Caracuan12
@Caracuan12 Жыл бұрын
You are the legend sir, thanks for these videos. I couldn't get the sunfounder kit as the link says "not available" in my country, but still invaluable lessons.
@davidbundy5365
@davidbundy5365 2 жыл бұрын
Thank you Paul. It's sometimes useful to background a python job. Inspired by your graceful cleanup, I found the kill signal SIGINT allows the process to terminate after doing the last 2 lines of code: GPIO.cleanup(), & print ('Thats all Folks').
@aman-sood
@aman-sood 2 жыл бұрын
Guys did you notice in this video Paul hooked the long leg to the LED DIRECTLY to the GPIO pin and the short leg of the LED to GND through a 330 ohms resistor. And the crazy part is, the circuit worked!! How??
@jabcek
@jabcek 2 жыл бұрын
Well what you are doing with the resistor is limiting the current. Usually the allowed current for LED's is 20mA (and Pi max output is 16mA). You are limiting the current regardless of where the resistor is located in a closed loop. So in this case with 3.3V and 330ohm resistor the current is 4.2mA. U=I*R ... U-voltage, I-current, R-resistance.
@JoRogan-l1v
@JoRogan-l1v Жыл бұрын
I am legend. Thank you again for the excellent tuition!
@TheScissorunner
@TheScissorunner 2 жыл бұрын
Changes this to a pull-down resistor by hooking Pin 40 to ground through a 10k resistor. This way Pin 40 sees ground or 0 when button is open. When button is pushed it will read a 1. Now the button reads 0 and Pin 38 can be set to output 0 when not pushed and when pushed the button reads 1 and Pin 38 is set to output 1.
@RobVollmar
@RobVollmar Жыл бұрын
I got a working solution combining the two functions down into one circuit but it didn't feel 'right' so I'm glad I worked through yours. I guess that makes me a Walmart Lawn Legend?
@MrCameronMoore
@MrCameronMoore 2 жыл бұрын
I am Legend. A simple piece of work, but satisfying when you press the button and the LED lights up : - ))
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Legend!
@sinaghadimi1804
@sinaghadimi1804 Жыл бұрын
Hey, I am watching your videos, I realized if you would have put your 3.3 Volts in up switch, then when you pull down the switch, you would have your reader, 10k resistor and ground! this way you don't have to change your code! i hope this makes sense thank you so much!
@simminator
@simminator 2 жыл бұрын
I AM LEGEND - Thanks for another great lesson!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
LEGEND!
@leeg.1402
@leeg.1402 2 жыл бұрын
Thanks for the video Paul.
@brucemilyko8549
@brucemilyko8549 Жыл бұрын
I am legend.I just did a GPIO.output(outPin,readval)
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@keneflucas937
@keneflucas937 10 ай бұрын
Hello Mr McWhorter and/or whoever may read this.....I could use a beginner's lesson on the 'try/except' function or clause. Why was it necessary in this program? What was the purpose of the timer?
@floridian080
@floridian080 2 жыл бұрын
Very helpful lesson, thanks. I notice that we did not need to set the button with the pull_up_down command as we have done before. Please explain when / why that command is superfluous.
@mohammedsakkal2063
@mohammedsakkal2063 2 жыл бұрын
Thank you for your helpful videos
@danielsaenz5570
@danielsaenz5570 2 жыл бұрын
Hi Paul, sadly I missed most of the premier, but I had to go to church. I think from now on I will import as KittyLitterBox! 😁 And I saw that you were doing python not python3, When I was following along, I made sure to python3 😉. Thanks Paul have a blessed Holy week, and Easter!!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
#HEISRISEN
@Lehibob
@Lehibob 2 жыл бұрын
Thanks Paul!
@ion4497
@ion4497 Жыл бұрын
wonderfull3 work3 paul3 jajaj just jocking great lesson and thanks from argentina !!!!!
@jonathanlanders9406
@jonathanlanders9406 Жыл бұрын
I am Legend! My code was almost identical to the solution that I had in the "New Arduino Tutorials". It was a little difficult to read with nano, but I definitely see the benefit of editing code directly from the terminal.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@davidverheyen6635
@davidverheyen6635 2 жыл бұрын
Thank you. Until now I did the gpio stuff with arduino... I might try with pi now. Am I missing something with the delay here? What does it do the way it's used?
@charlotteswift
@charlotteswift 2 жыл бұрын
Hi Paul You're always saying that you want more females taking your tutorials. Maybe there are more than you think but they're hidden in the shadows (and for good reason). I post my solutions for 3 reasons: - 1 To let you know that somebody out there is watching. 2 To show other people a (possibly cunning) solution. 3. To get some constructive feedback. It would be really useful if someone said 'You stupid woman! It would be much better if you did it like this'. Looking at many of the solutions with the comments made, it's like a Mutual Admiration Society. It's all "Wow! That's great!". What's the point of that? If you give some helpful criticism, it's as if you've told them that their children are ugly. I've seen someone rave about a fellow man's solution but, even though I came up with the same nifty idea, being a woman I just get comments (from the same person) about the pretty colours that I have used. I have left well paid jobs on three occasions because my life was made hell because the men couldn't cope with my being better than them. Sexism is a terrible thing to bear. I decided to go to university to get a degree as all my experience was in mainframe programming but there I was a victim of sexism AND ageism. I was only in my 30s but this seemed ancient to the boys just out of school. I will continue to support you on Patreon, I will watch your premieres when I can, I will continue to post my solutions, time permitting, but I will keep my mouth firmly shut! You're great, Paul but a message to some of the guys - 'Shame on you!!'
@woodturner1954
@woodturner1954 2 жыл бұрын
Charlotte, I am sorry you went thru so much trouble. When I was a network/database manager I had two very capable women work "with" me. They asked questions and I answered when I had an answer or told them were to go for better answers. Within 2 years they surpassed me in knowledge and capability and moved up the ladder so to speak. I have a niece who is the first family member to get a Bachelors Degree in 2 generations, she's a Elect/Mech Engineer and 3 very young grand nieces I hope to help guide to do anything they want. I can only say persevere and learn your past the idiots.
@butchh4004
@butchh4004 2 жыл бұрын
I could care less to what ever gender you are ! If you have a handle on this material , more power to you.
@charlotteswift
@charlotteswift 2 жыл бұрын
@@woodturner1954 Thanks, Curt. Maybe I'll change my online name to Chuck (and stop using pretty colours)
@charlotteswift
@charlotteswift 2 жыл бұрын
@@butchh4004 Thanks, Butch. As I said to Curt, maybe I'll change my online name to Chuck (and stop using pretty colours)
@maxq4515
@maxq4515 10 ай бұрын
Great session, thank you! Anyone noticed the ants yet?
@change4432
@change4432 2 жыл бұрын
God bless you Paul, if you don't mind please answer this question: Can I control 1 horsepower or higher power motor with Raspberry py?
@jabcek
@jabcek 2 жыл бұрын
You can, but with using relays. The GPIO pins are 3.3V and max current draw is 16mA
@mykyta1235
@mykyta1235 Жыл бұрын
IO.output(OUT_PIN, IO.input(IN_PIN)) instead of barrage of that if branching
@suelingsusu1339
@suelingsusu1339 2 жыл бұрын
@Mr. McWhorter... you can change the python command to run the python3.... In the /user/bin directory there is a LINK file that by default links to python2.... you can run a command to change this link sudo ln -fs /usr/bin/python3.7 /usr/bin/python This will do the work of changing the link to the python3.7 ... and thus you do not have to keep remembering to run python3 all the time. To run python2 just use python2.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Yes, you are correct, but if I do that, and in a later lesson someone sees me just type 'python' they will not know in an earlier lesson I had made that adjustment. I always have to think about people who might be just jumping into a specific video.
@suelingsusu1339
@suelingsusu1339 2 жыл бұрын
@@paulmcwhorter 👍👍🙏🙏🙏🖖🖖🖖
@butchh4004
@butchh4004 2 жыл бұрын
lesson 5 home work solution .Keep on getting various errors. solution: capitalise the B in the ward "BinCount". All is good now. Sincerely yours dyslexec.
@wendygrant2735
@wendygrant2735 2 жыл бұрын
I see differences with arduino. So this video was a good 'watch-out-or-you'll-be-burned' message for me.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
#DONTFRYYOURPI
@stacksof40
@stacksof40 5 ай бұрын
Basic, basic question.....in the initial circuit.....Pin 1 (3.3v) and Pin 40 (input GPIO) are separated only by a 10k ohm resistor. The Ohms Law calc states that would yield a current of only .00033amps. So why is the 'input' Pin 40 reading a '1'? Will any amperage, however miniscule - register as a '1? Feel like I am going backwards.......
@paulmcwhorter
@paulmcwhorter 5 ай бұрын
A '1' or '0' is determined by voltage, not current. Also, understand .0003 amps is by no means 'miniscule'. In electronic terms, most electronics work on microAmp (.000001 Amps) or nanoAmps (.000000001 Amps) levels, so .3 milliamps is large in electronics world
@cooperkeenan3037
@cooperkeenan3037 2 жыл бұрын
Hey Paul, love your videos, been watching a couple years now. But I have a problem with my raspberry pi. I put a post on stack overflow, would you mind having a look please?
@aman-sood
@aman-sood 2 жыл бұрын
Would you mind sending a link please?
@bartroels5980
@bartroels5980 3 ай бұрын
SLEEP was not used in the code?
@kalidabdul6862
@kalidabdul6862 2 жыл бұрын
Thank you paul I am legend
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
LEGEND!
@TheRealFrankWizza
@TheRealFrankWizza 2 жыл бұрын
I know you don't like if/else, but that was my solution. import RPi.GPIO as GPIO from time import sleep inPin=12 ledPin=13 GPIO.setmode(GPIO.BOARD) GPIO.setup(inPin,GPIO.IN) GPIO.setup(ledPin,GPIO.OUT) try: while True: readVal=GPIO.input(inPin) print(readVal) sleep(.1) if readVal==1: GPIO.output(ledPin,1) else: GPIO.output(ledPin,0) except KeyboardInterrupt: GPIO.cleanup()
@robinedminson6461
@robinedminson6461 Жыл бұрын
FYI Paul, My RPI OS only offers python3. May be something to pass on to later users. My OS downloaded August 2023
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Did you follow instructions in lesson 1 and start with the legacy Buster operating system?
@robinedminson6461
@robinedminson6461 Жыл бұрын
A-Ha, missed that bit. Many thanks :) @@paulmcwhorter
@rienwijnsma3410
@rienwijnsma3410 2 жыл бұрын
Hot coffee at the start of the day when everything is still quiet in the house. Maybe you can list the code somewhere?
@KarthikBhandary
@KarthikBhandary Жыл бұрын
I am legend. I connected the LED with the button directly instead of taking the power and ground from arduino.
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@KarthikBhandary
@KarthikBhandary Жыл бұрын
@@paulmcwhorter
@BibleConversationswithBros
@BibleConversationswithBros 4 ай бұрын
I am Legend.
@paulmcwhorter
@paulmcwhorter 4 ай бұрын
LEGEND!
@robinedminson6461
@robinedminson6461 Жыл бұрын
I am legend :)
@ettienemare
@ettienemare Ай бұрын
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) try: while True: is_on = GPIO.input(input_pin) GPIO.output(led_pin, is_on) time.sleep(0.2) except KeyboardInterrupt: pass GPIO.cleanup()
@alfredoazcona8752
@alfredoazcona8752 2 жыл бұрын
I AM LEGEND
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
LEGEND!
@foam_ranther141
@foam_ranther141 2 ай бұрын
i am legend , i made a binary counter with push button .
@paulmcwhorter
@paulmcwhorter Ай бұрын
LEGEND!
@nakamuable
@nakamuable Жыл бұрын
I am legend
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@DAVRO77
@DAVRO77 Жыл бұрын
Just to say: I pour a good, hot and suggared cup of my greentea infusion and not coffee XD But @paulmcwhorter I'll never thank you enough for these courses.
@syohomuga
@syohomuga 4 ай бұрын
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) inPin=40 outPin=22 GPIO.setup(inPin, GPIO.IN) GPIO.setup(outPin, GPIO.OUT) try: while True: readVal = GPIO.input(inPin) if readVal ==1: GPIO.output(outPin, 1) if readVal ==0: GPIO.output(outPin, 0) sleep(0.1) except KeyboardInterrupt: GPIO.cleanup()
Raspberry Pi LESSON 7: GPIO Inputs from Button Switch
24:52
Paul McWhorter
Рет қаралды 19 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 138 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 31 МЛН
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 235 МЛН
Pull-up and pull-down resistors explained
6:33
Blueprint IoT
Рет қаралды 10 М.
Raspberry Pi LESSON 5 HOMEWORK SOLUTION: Understanding Binary Numbers
1:01:47
Computer Inputs: Pull-Up and Pull-Down Circuits
11:45
Justin Miller
Рет қаралды 35 М.
Raspberry Pi GPIO - Getting Started with gpiozero
48:40
DroneBot Workshop
Рет қаралды 446 М.
Raspberry Pi 5: Video Editing, Video Calling & Passive Cooling
20:09
ExplainingComputers
Рет қаралды 132 М.
Short and sweet:  pull up/pull down resistors explained
6:16
learnelectronics
Рет қаралды 137 М.
Raspberry Pi LESSON 2: Linux Essentials in One Session
1:01:59
Paul McWhorter
Рет қаралды 68 М.
Control you Raspberry Pi with a BUTTON
12:03
Sam Westby Tech
Рет қаралды 23 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 138 МЛН