User Tools

Site Tools


gpio_controlled_leds

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gpio_controlled_leds [2026/06/17 16:30] – [Introduction] walkeradmingpio_controlled_leds [2026/06/30 21:01] (current) walkeradmin
Line 13: Line 13:
 \\  \\ 
 \\  \\ 
-{{ :pico-non-wireless-pinout-with-leds-wiring.png?400 |}}+{{ :pico-non-wireless-pinout-with-leds-wiring.png?300 |}}
 \\  \\ 
 We have wired the LEDs to GPIO pins 2, 6 & 10. These are the GPIO Pin numbers, not the actual Pi Pico Pin numbers. We have wired the LEDs to GPIO pins 2, 6 & 10. These are the GPIO Pin numbers, not the actual Pi Pico Pin numbers.
Line 20: Line 20:
 Below is the software being used to drive the LEDs Below is the software being used to drive the LEDs
 \\  \\ 
-<code | download>+<code:python | download>
 # Start by importing lib files "machine" & "time" # Start by importing lib files "machine" & "time"
 # Imports the machine module, which provides access to hardware features such as GPIO pins, ADCs, PWM, etc. # Imports the machine module, which provides access to hardware features such as GPIO pins, ADCs, PWM, etc.
Line 27: Line 27:
 import time import time
  
-#we're initalizing pin 25 (which is the onboard LED) & pins 2, 6 and as outputs+#we're initalizing pin 25 (which is the onboard LED) & GPIO pins 2, 6 and 10 as outputs (These are the GPIO numbers, not the actual pin numbers around the PCB).
 # Creates a pin object called led1. # Creates a pin object called led1.
 # Uses GPIO pin 25. # Uses GPIO pin 25.
Line 33: Line 33:
 # On a Raspberry Pi Pico, GPIO 25 is usually connected to the onboard LED. # On a Raspberry Pi Pico, GPIO 25 is usually connected to the onboard LED.
 led1 = machine.Pin(25, machine.Pin.OUT) led1 = machine.Pin(25, machine.Pin.OUT)
-# Creates an output pin object for GPIO 2.+# Creates an output pin object for GPIO 2 (GP2).
 led2 = machine.Pin(2, machine.Pin.OUT) led2 = machine.Pin(2, machine.Pin.OUT)
-# Creates an output pin object for GPIO 6.+# Creates an output pin object for GPIO 6 (GP6).
 led3 = machine.Pin(6, machine.Pin.OUT) led3 = machine.Pin(6, machine.Pin.OUT)
-# Creates an output pin object for GPIO 10.+# Creates an output pin object for GPIO 10 (GP10).
 led4 = machine.Pin(10, machine.Pin.OUT) led4 = machine.Pin(10, machine.Pin.OUT)
  
Line 87: Line 87:
 The software works by performing the following tasks. The software works by performing the following tasks.
 \\  \\ 
-    Import Libraries (Machine and Time) +  * Import Libraries (Machine and Time) 
-     + 
-    Set GPIO Pins to output +  * * Set GPIO Pins to output 
-     + 
-    Start a loop that will loop 5 times +  Start a loop that will loop 5 times 
-     + 
-    Turn on the first LED and turn off all other LEDs +  Turn on the first LED and turn off all other LEDs 
-     + 
-    Turn on the second LED and turn off all other LEDs+  Turn on the second LED and turn off all other LEDs
  
-    Turn on the third LED and turn off all other LEDs+  * Turn on the third LED and turn off all other LEDs
  
 That's it. Pretty simple. Remember, you can control other devices using the GPIO pins other than LEDs, but the current output is limited to around 20mA. If you try to pull more than this, you could damage that GPIO Pin. That's it. Pretty simple. Remember, you can control other devices using the GPIO pins other than LEDs, but the current output is limited to around 20mA. If you try to pull more than this, you could damage that GPIO Pin.
gpio_controlled_leds.1781713821.txt.gz · Last modified: by walkeradmin