Do something real with python
You've slaved away learning python - but really haven't done anything in the real world? How about controlling a raspberry pi ?
Raspberry Pi can be programmed in almost any language - but most often uses python to control the general purpose input output pins - giving the Raspberry Pi microcomputer the ability to control real things
For example - consider the following. It counts up in binary with LEDs, then reads a button to reset the count. Here's the python code.
# example of programming Raspberry Pi GPIO with gpiozero # refer to gpiozero.readthedocs.io import gpiozero as gpzero from time import sleep # set up pushbutton and bank of leds resetbutton = gpzero.Button(3) leds = gpzero.LEDBoard(26,16,20,21) # functions to control behavior def LightsOn (): while resetbutton.is_pressed: leds.on() def ResetCounter (): global counter leds.off() counter = 0 def binary2lights(showThis): leds.value = ( showThis & 0b1000, showThis & 0b0100, showThis & 0b0010, showThis & 0b0001) # setup button handlers resetbutton.when_pressed = LightsOn resetbutton.when_released = ResetCounter # send 0...15 to lights while True: ResetCounter() while counter < 16: binary2lights(counter) counter += 1 sleep(1)
LEDs are the "Hello World" example when the virtual world of programming meets the physical world of you and I. If that's a bit abstract, take a look at this instructional video from LinkedIn Learning...
Interested in more on Raspberry Pi? Please subscribe to this newsletter.