This series is a goldmine! Thank you dear Paul! Since the power is small here I used only one resistor from ground rail where all LED's are connected and connected them through 1k (330 ohms is too bright for my eyes, even 10k works well) resistor to the GND or (-)
@keyboardlearning75522 жыл бұрын
In the past, I would have counted from 0 to 31 in a for-loop, and then decoded the decimal number to binary. For this exercise, I created an array, to store the 5 '1's and '0's, and then did the math in binary, by starting the loop through with toggling bit[1] from '0' to '1', and then when toggling from '1' to '0', setting a 'Carry' flag. For bit[2] to [5], using the Carry flag to indicate the need to set, or reset the bit, turning the LED On, (or Off) and managing the Carry flag, as necessary. Your way was simpler. Many thanks for this new series.
@TuckerSidhu10 ай бұрын
I am really enjoying your lessons and am learning so much. Here's my code for this lesson: # Blink 5 LED in Binary counting from 0 to 31 import RPi.GPIO as GPIO from time import sleep # Setup GPIO Pins GPIO.setmode(GPIO.BCM) GPIO.setup(5,GPIO.OUT) GPIO.setup(6,GPIO.OUT) GPIO.setup(13,GPIO.OUT) GPIO.setup(19,GPIO.OUT) GPIO.setup(26,GPIO.OUT) # Initialize setup a = 0 b = 0 c = 0 d = 0 e = 0 temp = 0 # Create a function to convert from Base10 to Base2 def Convert_base10_base2(i): a = i % 2 temp = i // 2 b = temp % 2 temp = temp // 2 c = temp % 2 temp = temp // 2 d = temp % 2 temp = temp // 2 e = temp % 2 return a, b, c, d, e # Light up each binary number for i in range(0,32,1): a,b,c,d,e = Convert_base10_base2(i) GPIO.output(5,a), GPIO.output(6,b), GPIO.output(13,c), GPIO.output(19,d), GPIO.output(26,e) sleep(1) GPIO.cleanup()
@aaroncarman2 жыл бұрын
There are 10 types of people in this world: Those who understand binary, and those who don't.
@WilliamLundy-e5t9 ай бұрын
Ok took me awhile to get it right but your method was much simpler for us just starting to write code then some of the solutions that others had entered on KZbin. I am having fun doing this so it is keeping me busy at 73 years of age
@TheScissorunner Жыл бұрын
Yeah! Raspberry Pi finally arrived so I can start the lessons! In the meantime I completed the Paul McWhorter Python lessons and did a considerable amount of additional Python learning. Here is my take on the binary counter; import RPi.GPIO as PIN # 'PIN' can be named anything you like # PIN.setmode(PIN.BOARD) # use for board pin numbering scheme PIN.setmode(PIN.BCM) # use for BCM pin numbering scheme from time import sleep # Set GPIO pin numbers led1 = 4 led2 = 17 led3 = 27 led4 = 22 led5 = 26 # Setup pins as outputs PIN.setup(led1, PIN.OUT) PIN.setup(led2, PIN.OUT) PIN.setup(led3, PIN.OUT) PIN.setup(led4, PIN.OUT) PIN.setup(led5, PIN.OUT) # Send command to all pins to turn them off, '0' does this PIN.output(led1, 0) PIN.output(led2, 0) PIN.output(led3, 0) PIN.output(led4, 0) PIN.output(led5, 0) # Create for loop to count. Create a list that formats the count # and outputs to a binary Python list. example [0, 1, 1, 0, 1] is 13 for i in range(0, 32): lst = [int(i) for i in format(i, '07b') [2:]] print(str(i) + " to binary: " + str(lst)) sleep(.5) # Use the list and list indexing to assign 0 or 1 value to led output pin PIN.output(led1, lst[4]) PIN.output(led2, lst[3]) PIN.output(led3, lst[2]) PIN.output(led4, lst[1]) PIN.output(led5, lst[0]) sleep(5) PIN.cleanup()
@jonathanlanders9406 Жыл бұрын
I am legend! I did this project back in the "New Arduino Tutorials, so I decided to make the assignment a little more complex by using if and elif statements to turn the LEDs on and on. 1. The Code uses if-statements to first checks to see if the 1splace LED is on or off (x1). It then determines if a one will be carried over to the next place. 2. The second set of if-statements checks to see if a one was carried over from the 1splace. Depending on the answer, the program will turn or turn off the x2 LED and determine if a 1 is carried over to the 4splace. 3. Step 2 is repeated for all the LEDs. 4. The final if-statement determines if a one is carried from the 16splace to the 32splace. 4A. If the answer is now, the code starts back at step 1. 4B. If the answer is yes, their is now more places to dump in the 1, so the program exits the while loop. Due to the number of necessary if-statements and variable required, it probably took as long to write this code as Mr. McWhorter's solution, but it was good practice. If I had time to go back and do it, I would create a function. It would make the code so much cleaner Great lessons as always!
@paulmcwhorter Жыл бұрын
LEGEND!
@WilliamBurlingame2 жыл бұрын
Here is my code for the lesson 5 assignment. I retired as a programmer in 1998, but I'm rather new to Python and Linux. I wrote a program that I think handles a variable number of bits. The GPIO assignments make that not entirely true. I had to do a lot of Googling to solve the problem. I know I've gone beyond the scope of the lesson, but I couldn't get a good nights sleep until I solved the problem. I also had a HW problem. I discovered a resistor measured much higher than it should be. The corresponding LED was very dim. The resistor was not from my SunFounder kit, but from an old Arduino kit. # Binary counter with LEDs # Works with variable number of bits, except for GPIO assignments import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(29,GPIO.OUT) GPIO.setup(31,GPIO.OUT) GPIO.setup(33,GPIO.OUT) GPIO.setup(35,GPIO.OUT) GPIO.setup(37,GPIO.OUT) On = True Off = False import time OnTime = 1 OffTime = .25 i = 0 #Number counter j = 0 #Bit index num_bits = 5 max_binary_values = 2**num_bits GPIO_Num = (37, 35, 33, 31, 29) #LED GPIO pin numbers - Reverse pin numbers if needed LED_Status = [] LED_Status = [Off for i in range(number of bits)] #Set Array size i = 0 while i < max_binary_values: b = bin(i)[2:] #Convert Number to string of ones and zeros, ignore leading 0b b = b.zfill(num_bits) #Pad String with zeros if less than number of bits j = 0 while j < num_bits: #Turn off all LEDs GPIO.output(GPIO_Num[j],Off) #turn LED Off# print(j) j = j + 1 time.sleep(OffTime) j = 0 while j < num_bits: #Set LED_Status Array for current binary number binarydigit = int(b[j]) if binarydigit == 0: LED_Status[j] = Off if binarydigit == 1: LED_Status[j] = On j = j + 1 j = 0 while j < num_bits: #turn on LED Pattern GPIO.output(GPIO_Num[j],LED_Status[j]) j = j + 1 time.sleep(OnTime) i = i + 1 GPIO.cleanup()
@michealmyers4515 Жыл бұрын
That's smart!
@andrewgeary9749 Жыл бұрын
I'm just doing this series now (chip shortage) and I'm thankful to see a programing solution that could go on without the copy/paste business, assumed that is what we'd learn.
@charlotteswift2 жыл бұрын
Thanks, Paul. Jolly good lesson!! I would never thought of putting the resistors going down across the gap and I will also be getting some of those short wires.
@ryanrangel7822 жыл бұрын
Me and my friend Eshhu are your biggest fans!! We Watch all ur arduino videos and happily on video 52! Keep up the good work!!!
@kyriakospapadopoulos39722 жыл бұрын
Always loving the breadboard wandering ants!
@michealmyers4515 Жыл бұрын
The rain and storm had no effect on your quality of teaching...hats off!
@danielsaenz55702 жыл бұрын
Haha, yet another ant on your breadboard! at: 40:24 !! It stays on the board until 42:22 Thanks Paul for another lesson!
@RobVollmar Жыл бұрын
I did achieve legendary status but I used your instruction here to improve my circuit layout. I'm using the RP400 so it gets a bit claustrophobic building out from the back of the keyboard. I'm going to invest in a breakout cable to make it a bit easier moving forward.
@terryneves157312 күн бұрын
The series is amazing and I am learning a lot! The one question I have is why hardcode the leds for each number. In my solution I used a loop where I used the bin(I)[2:].zfill[5] to get the num in binary, I converted to a string to be able to access each position by index, then when I had the 0 or 1 for each position I mapped the value to the led as an int - 0 or 1 - and used that to turn the led on or off. It seemed like less work to me.
@paulmcwhorter11 күн бұрын
I have not taught those things in the earlier lessons. I only use techniques that I have already taught in the class.
@peterkarlsson78012 жыл бұрын
I'm glad there were only 5 red LEDs in the kit...
@ettienemareАй бұрын
I enjoyed the lesson here is my solution. import RPi.GPIO as GPIO import time pins = [4, 17, 27, 22, 25] GPIO.setmode(GPIO.BCM) for i in range(5): GPIO.setup(pins[i], GPIO.OUT) for i in range(0,32): binary_string = format(i, '05b') for j in range(5): GPIO.output(pins[j], int(binary_string[j])) time.sleep(1) GPIO.cleanup()
@11irishjs512 жыл бұрын
We did it this way: import RPi.GPIO as rp import time rp.setmode(rp.BOARD) pin_list = [29,31,33,35,37] for pin in pin_list: rp.setup(pin,rp.OUT) for counter in range(2**len(pin_list)): print(counter) time.sleep(.25) for pin in pin_list: if not rp.input(pin): rp.output(pin,True) break elif rp.input(pin): rp.output(pin,False) rp.cleanup() We had to look up how to detect if a pin had voltage and it was pretty simple with 'rp.input(pin)' returning a boolean value on the state of containing voltage or not. This method makes it very easy to add more LEDs, as we only have to modify the 'pin_list'.
@brucemilyko8549 Жыл бұрын
I am legend. I did not use any jumper wires and instead plugged all the LEDs into the top ground rail. I did use the same GPIO pins but in the reverse order. My code is much more compact. for num in range (32): bNum = format (num,'05b') GPIO.output(29,int(bNum[0])) GPIO.output(31,int(bNum[1])) GPIO.output(33,int(bNum[2])) GPIO.output(35,int(bNum[3])) GPIO.output(37,int(bNum[4])) time.sleep(1)
@yvesmueller7299 Жыл бұрын
Thats the way!
@codecage9333 Жыл бұрын
Well I guess I folded, but not quite like a cheap WalMart lawn chair. I was trying to use some sort of looping code with a counter, but folded before watching your solution. But after you defined the 0 - 15 count, why not just copy and paste those 16, then all you would have had to edit would have been turning on LED5 on the second block of 16?
@gonepostal63 Жыл бұрын
I am legend-ish. I couldn't bear the thought of doing a manual count, so I just used a for loop to count to 31 and manually decoded it to binary with 5 if-then-else statements like this. It could have been neater, with less repetition, but I haven't quite figured out how. Part of the code: loop here # section E leftmost if counter > 15: counter = counter - 16 ledEState = True else: ledEState = False # section D if counter > 7: counter = counter - 8 ledDState = True else: ledDState = False # section C if counter > 3: counter = counter - 4 ledCState = True else: ledCState = False # section B if counter > 1: counter = counter - 2 ledBState = True else: ledBState = False # section A rightmost if counter == 1: ledAState = True else: ledAState = False GPIO.output(LED_A, ledAState) GPIO.output(LED_B, ledBState) GPIO.output(LED_C, ledCState) GPIO.output(LED_D, ledDState) GPIO.output(LED_E, ledEState)
@floridian0802 жыл бұрын
I wanted to enlarge on my comment on the pi400 and sense hat. The sense hat is one of the more interesting components of the Pi b/c is has accompanied astronauts on a mission or two along with student projects. It made the binary coding lesson easier and perhaps more esthetic. On the other hand, the sense hat does not seem easy (and maybe not possible) to use with push buttons on a breadboard, which is rather frustrating. As consolation though, it has a built in joystick which might be used to substitute for some button functions. Since almost every project on a breadboard seems harder to accomplish with a Pi than an Arduino, I like Paul's idea of using the Pi for 2nd level visualization and elaboration of Arduino data with the exception that the sense hat makes it easy to do some data gathering as well. For example, the sense hat has built in temperature and humidity sensors, joystick, altimeter, and of course the 8X8 pixel display which can also substitute for a TFT or LCD.
@paulmcwhorter2 жыл бұрын
Yet part of what I am trying to do is teach things the hard way. Meaning, assembling things on a breadboard leads to mistakes, and that leads to troubleshooting and frustration, and that leads to building skills. My goal is maximize skill building, and sometimes that skill building is less if the package is preconfigured and all you do is plug it in. So, that is my rational.
@PrabudhGoel-x6i4 ай бұрын
Paul - my 8yo son and I are learning RPi together from your excellent videos. Thank you for the taking the time to create this content! Here is our code, would love feedback if any: import RPi.GPIO as gpio gpio.setmode(gpio.BOARD) gpio.setup(11,gpio.OUT) gpio.setup(13,gpio.OUT) gpio.setup(15,gpio.OUT) gpio.setup(29,gpio.OUT) gpio.setup(31,gpio.OUT) import time p1,p2,p3,p4,p5 = 0,0,0,0,0 binary = [p5,p4,p3,p2,p1] for p5 in range(0,2,1): binary = [p5,p4,p3,p2,p1] for p4 in range(0,2,1): binary = [p5,p4,p3,p2,p1] for p3 in range(0,2,1): binary = [p5,p4,p3,p2,p1] for p2 in range(0,2,1): binary = [p5,p4,p3,p2,p1] for p1 in range(0,2,1): binary = [p5,p4,p3,p2,p1] print(binary) time.sleep(1) gpio.output(11,p1) gpio.output(13,p2) gpio.output(15,p3) gpio.output(29,p4) gpio.output(31,p5) time.sleep(1) gpio.output(11,0) gpio.output(13,0) gpio.output(15,0) gpio.output(29,0) gpio.output(31,0) gpio.cleanup()
@paulmcwhorter4 ай бұрын
Excellent!
@larryplatzek90172 жыл бұрын
good lesson!
@paulmcwhorter2 жыл бұрын
Thanks! 😃
@mykyta1235 Жыл бұрын
Thanks a lot, Sir Paul!
@bhnienhuis10 ай бұрын
Hi Paul, great series, thank you! Is the source code for your solutions somewhere available for download? I’d like to keep your code next to mine for comparison.
@herrjonatan5436 Жыл бұрын
I made thesame program but in Arduino Thanks for the solution in python Sir
@JoRogan-l1v Жыл бұрын
I am legend. Thank you once again!
@paulmcwhorter Жыл бұрын
LEGEND!
@steveschad1036 ай бұрын
My first thought was to do it this way but then I thought that's way too many lines of code, that can't be right lol. I created a 'for' loop with an 'if' statement and got them to turn on at the right time, but they didn't turn off so by 16 all LEDs were on. My next idea was to make a 1x5 array of 1's and 0's but didn't know the code to convert the number into binary but still thought for sure I needed to use a loop. For my wiring, I put the short end of the LEDs on the grnd bus so I didn't have to ground each one with a wire 😁 Edit: I found someone else who did what I was trying to do. I didn't use the 'else' statement to switch LEDs back off lol.
@harrison4687 Жыл бұрын
Interesting that there were so many different solutions to this homework.
@Lehibob2 жыл бұрын
Thanks Paul for the lesson and the homework assignment / solution vids! I'm really appreciating your teaching style and your effort in doing this for us! I do have one question... Which brand/model sketchpad and software are you using with the cool engineering graph background? I'd love to have one just like it!
@paulmcwhorter2 жыл бұрын
I am using autodesk sketchpad running on an ipad pro. I can not do well with the cheap sketchpads that dont let you see right under the stylus what you are writing. Then I take output of ipad and feed to the blackmagic capture board on my PC
@mystery_1101 Жыл бұрын
35:38 is it only me who saw a ant? Thought it was on my screen lol
@skordsoriginal8 ай бұрын
it is there around 12min too
@miraq1118 Жыл бұрын
I am legend, thank u Paul 🙏
@paulmcwhorter Жыл бұрын
LEGEND!
@ettienemareАй бұрын
my improved algorithm import RPi.GPIO as GPIO import time pins = [4, 17, 27, 22, 25] GPIO.setmode(GPIO.BCM) for i in range(len(pins)): GPIO.setup(pins[i], GPIO.OUT) for i in range(0, 2**len(pins)): binary_string = format(i, f'0{len(pins)}b') for j in range(len(pins)): GPIO.output(pins[j], int(binary_string[j])) time.sleep(1) GPIO.cleanup()
@mrdarbab2 жыл бұрын
thank god for shift registers.
@peterwooldridge72852 жыл бұрын
I think using the bin() function in combination with the slice() function ( to remove the sign( ie "Ob" ) a the start of the binary number) looping through an array of integers (e.g. 1- 31) is perhaps a more efficient way to obtain the binary numbers......just a thought
@paulmcwhorter2 жыл бұрын
Yet at this early stage of the lessons, I am trying to get students to understand binary and then to know how to use the GPIO pins. Later we can think at more advanced levels, but at this point just giving little steps at a time.
@peterwooldridge72852 жыл бұрын
@@paulmcwhorter no worries.....and thanks so much for giving of your time and knowledge it's very much appreciated
@keithlohmeyer2 жыл бұрын
Peter, Great minds think alike. Check out my homework video. kzbin.info/www/bejne/Zpyon5ZojrZnabM
@ion4497 Жыл бұрын
great lesson paul . where is that beautiful place behind you ?
@paulmcwhorter Жыл бұрын
It is the headwaters of the Nile River.
@charlotteswift2 жыл бұрын
Hi Paul Sorry I missed you live because my internet was down due to gales. It keeps breaking so I haven't done a video but my code is in the comments on the last lesson. I'll look at your solution and everybody else's tomorrow. Probably mine isn't as good 😿
@Lehibob2 жыл бұрын
Okay.... another question. Do you have a reason why you are not using an IDE such as Thonny for these lessons? Do you have any lessons that use Thonny that you've done in the past? I ask because I had never heard of it until I watched lesson 1 in this series when you happened to mention it in passing. I looked at it and it seems just right for these kinds of projects, and the editing functions are actually fairly sophisticated.
@paulmcwhorter2 жыл бұрын
yes. I want students to learn how to program old school. A python program is JUST TEXT. The interpreter takes the TEXT and then interprets it line by line and executes it line by line. Jumping into an IDE, students think the IDE is running the code. The IDE is just a more advanced text editor. I want them to learn the basics. We do move to Thonny in about 5 more lessons or so.
@stephenrose7882 жыл бұрын
Hi Paul, As this part of the course is focused on understanding the binary nature of computers, this would have been a great place to introduce python's binary operators. This would have allowed you to use a user-defined function making use of the '&' (binary AND) to determine the LEDs to light for each number. Duplicating code over and over leads to errors such as you encountered, and makes the code difficult to read and maintain.
@paulmcwhorter2 жыл бұрын
Yet what I am trying to do is give new learners little bite size amounts. I want them to understand binary numbers. We can later get more advanced ways to interact with them. Baby steps at a time for new learners.
@FushigiMigi Жыл бұрын
I thought the project was to convert a decimal number(user input) into binary and blink the binary on the LEDs. That would have required time which I didn't feel was worth it. Good thing I skipped to the answer video.
@kainjohnson22802 жыл бұрын
I wish u were my math teacher
@paulmcwhorter2 жыл бұрын
I wish you were my student!
@charlotteswift2 жыл бұрын
@@paulmcwhorter I bet you don't wish that I were your student!! 😼
@martinlewis645 Жыл бұрын
@danielsaenz55702 жыл бұрын
How do you make a computer say 5? Its binary 101
@donaldwaddel46007 ай бұрын
I'm getting a real kick rehashing some things I haven't thought about since I took an assembly class in the early 1980's. Back in the days of punch cards and mainframes! Here's a link to a perpetual 0-31 counter using bitwise OR's to trigger the LED's. Keep up the great work! While I have it wired up I'm going to do left and right bitwise shifts. Love watching those LED's dance! kzbin.infowhcFOp4OK6E?feature=share
@MaxwellGu6 ай бұрын
I messed up at the start. Then I reworked it. Blown out of the water.
@uiru84559 ай бұрын
import time import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.OUT) GPIO.setup(13,GPIO.OUT) GPIO.setup(15,GPIO.OUT) GPIO.setup(19,GPIO.OUT) GPIO.setup(21,GPIO.OUT) for i in range(0,32,1): if i >= 16 : i=i-16 GPIO.output(21,1) else : GPIO.output(21,0) if i >= 8: i=i-8 GPIO.output(19,1) else: GPIO.output(19,0) if i >= 4: i=i-4 GPIO.output(15,1) else: GPIO.output(15,0) if i >= 2: i = i-2 GPIO.output(13,1) else: GPIO.output(13,0) if i == 1: GPIO.output(11,1) else: GPIO.output(11,0) time.sleep(1/2) time.sleep(3) GPIO.cleanup()
@JayRawat-cj5no11 ай бұрын
Who noticed that ant on board 😂36:39
@larryplatzek90172 жыл бұрын
Paul what will the live chat tonight be called!
@paulmcwhorter2 жыл бұрын
#RESISTTHEMETAVERSE
@Steek.K3 ай бұрын
I AM LEGEND💪
@paulmcwhorter3 ай бұрын
LEGEND!
@kumarnew1004 ай бұрын
Hello Sir . I am form India. Once run the program I am getting permission denied
@ettienemareАй бұрын
try sudo
@snowman58able2 жыл бұрын
kzbin.info/www/bejne/epa2Y6KLbsqmjqM This is a link to my solution to the binary led homework. It's very different from the one presented in the lesson 5 homework solution.
@paulmcwhorter2 жыл бұрын
Excellent!
@bozinoski Жыл бұрын
I'm a Legend LOL. I'm sure there's an easier way to do it, but my solution worked as intended. It is not scalable however, the solution only works for number up to 31. I have an idea how to make it work with any number and more LEDs but since I've never worked with Python I though this solution is good enough for now. This is my code: import numpy as np import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.OUT) GPIO.setup(12,GPIO.OUT) GPIO.setup(37,GPIO.OUT) GPIO.setup(8,GPIO.OUT) GPIO.setup(29,GPIO.OUT) def b0(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,0)] def b1(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,1)] def b2(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,0)] def b3(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,1)] def b4(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,0)] def b5(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,1)] def b6(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,0)] def b7(): return [GPIO.output(29,0),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,1)] def b8(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,0)] def b9(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,1)] def b10(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,0)] def b11(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,1)] def b12(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,0)] def b13(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,1)] def b14(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,0)] def b15(): return [GPIO.output(29,0),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,1)] def b16(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,0)] def b17(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,1)] def b18(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,0)] def b19(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,1)] def b20(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,0)] def b21(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,1)] def b22(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,0)] def b23(): return [GPIO.output(29,1),GPIO.output(8,0),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,1)] def b24(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,0)] def b25(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,0),GPIO.output(37,1)] def b26(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,0)] def b27(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,0),GPIO.output(12,1),GPIO.output(37,1)] def b28(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,0)] def b29(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,0),GPIO.output(37,1)] def b30(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,0)] def b31(): return [GPIO.output(29,1),GPIO.output(8,1),GPIO.output(11,1),GPIO.output(12,1),GPIO.output(37,1)] arr = [b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,b28,b29,b30,b31] cont = "y" while cont == "y": userInput = int(input("What number would you like to count up to in binery? ")) for i in np.linspace(1,userInput,userInput): time.sleep(.5) arr[int(i)]() time.sleep(2) b0() cont = input("Would you like to continue? y/n ") GPIO.cleanup()
@dhruvjain52402 жыл бұрын
I am Legend
@paulmcwhorter2 жыл бұрын
LEGEND!
@daviddirac59422 жыл бұрын
I am legend
@paulmcwhorter2 жыл бұрын
LEGEND!
@bhnienhuis10 ай бұрын
My solution: import time import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(22, GPIO.OUT) GPIO.setup(32, GPIO.OUT) GPIO.setup(36, GPIO.OUT) GPIO.setup(38, GPIO.OUT) GPIO.setup(40, GPIO.OUT) def switch_leds(num): binary_string = format(num, f'0{5}b') GPIO.output(22, int(binary_string[0])) GPIO.output(32, int(binary_string[1])) GPIO.output(36, int(binary_string[2])) GPIO.output(38, int(binary_string[3])) GPIO.output(40, int(binary_string[4])) for j in range(0,3): for i in range(0, 32): switch_leds(i) time.sleep(0.3) GPIO.cleanup()
@larryplatzek90172 жыл бұрын
what happened to the other comments ?
@paulmcwhorter2 жыл бұрын
I dont understand what you are asking. Which other comments?
@leeg.14022 жыл бұрын
I agree. It seems other comments have been eliminated from this video (and other videos in this and many of your other series)
@larryplatzek90172 жыл бұрын
@@paulmcwhorter Paul keith Lowmeyer had a link to his answer homework 5 also charlette had posted her home work. Sorry did not reply sooner have been out of town. and very tired.
@larryplatzek90172 жыл бұрын
I found Keith's post in lesson 5 comments. I guess was too tired and missed it,
@genepierson17282 жыл бұрын
Great assignment. But I'm surprised you didn't use an array since that was in one of the previous lessons. Like this: x =[[0,0,0,0,1],[0,0,0,1,1],[0,0,0,1,1],[0,0,1,0,0]]...and so on Then a for loop to turn on the LEDs. Like this: for i in range (0,31,1): GPIO.output(29,x[i][0] GPIO.output(31,x[i][1]) and so on...
@OZtwo Жыл бұрын
Yes, I was kind of let down on this video. WAS a fun project.
@carol-lo Жыл бұрын
This is so great!
@PapaKn2 жыл бұрын
Finally got my kit and hooked up my Pi to finish the homework assignment! Thanks Paul! kzbin.info/www/bejne/Z3bKqotujJqjd5o