I learned to use Python on my Raspberry Pis. Building electronic circuits on the breadboard and controlling them with a Python program is a lot of fun.
BTW, the electronic circuit kits I bought came with Python and C code. Unfortunately, the code was developed to run on Raspberry Pi 3 and 4s. The code as is doesn't t work on a Raspberry Pi 5 because the architecture changed on it causing the libraries to break. I had to rewrite the code using compatible libraries.
You might try a headless boot of the Raspberry Pi 5 and control it with a laptop. I keep my Raspberry Pi 5 on a coffee table and plug it in when I want to use it. Using the laptop saves having to go and get a monitor, keyboard and mouse.
Actually learning Python was the easiest part. Learning to use the libraries was harder. The libraries are used to communicate with the Rapsberry Pi GPIO pins
Here is the Python code used to control a dual-color LED on the breadboard. The library used is called gpiozero.
BTW, the electronic circuit kits I bought came with Python and C code. Unfortunately, the code was developed to run on Raspberry Pi 3 and 4s. The code as is doesn't t work on a Raspberry Pi 5 because the architecture changed on it causing the libraries to break. I had to rewrite the code using compatible libraries.
You might try a headless boot of the Raspberry Pi 5 and control it with a laptop. I keep my Raspberry Pi 5 on a coffee table and plug it in when I want to use it. Using the laptop saves having to go and get a monitor, keyboard and mouse.
Actually learning Python was the easiest part. Learning to use the libraries was harder. The libraries are used to communicate with the Rapsberry Pi GPIO pins
Here is the Python code used to control a dual-color LED on the breadboard. The library used is called gpiozero.
#!/usr/bin/env python3
#modified for Raspberry Pi 5
from gpiozero import PWMLED
import time
colors = [0xFF00, 0x00FF, 0xFFFF, 0x0000]
pins = (17, 18) # pins is a dict GPIO17, GPIO18
def map(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
def setup():
p_R = PWMLED(pins[0], frequency = 2000) # set Frequece to 2KHz
p_G = PWMLED(pins[1], frequency = 2000)
p_R.off() # Initial duty Cycle = 0(leds off)
p_G.off()
return p_R, p_G
def setColor(col): # For example : col = 0x1122
R_val = col >> 8
G_val = col & 0x00FF
R_val = map(R_val, 0, 255, 0, 1)
G_val = map(G_val, 0, 255, 0, 1)
p_R.value = R_val # Change duty cycle
p_G.value = G_val
def loop():
while True:
for col in colors:
setColor(col)
time.sleep(3)
def destroy():
p_R.off()
p_G.off()
if __name__ == "__main__":
p_R, p_G = setup()
try:
loop()
except KeyboardInterrupt:
destroy()
Last edited:
My Computers
-
At a glance
Windows 11 Pro 25H2 (26200.6901)AMD Ryzen 7 6800H with Radeon 680M GPU (486MB...Crucial DDR5-4800 (2400MHz) 32GB (2 x 16GB)NVIDIA RTX 3060 Laptop (6GB RAM)- OS
- Windows 11 Pro 25H2 (26200.6901)
- Computer type
- Laptop
- Manufacturer/Model
- ASUS TUF Gaming A15 (2022)
- CPU
- AMD Ryzen 7 6800H with Radeon 680M GPU (486MB RAM)
- Memory
- Crucial DDR5-4800 (2400MHz) 32GB (2 x 16GB)
- Graphics Card(s)
- NVIDIA RTX 3060 Laptop (6GB RAM)
- Sound Card
- n/a
- Monitor(s) Displays
- 15.6-inch
- Screen Resolution
- 1920x1080 300Hz
- Hard Drives
- 2 x Samsung 990 Evo Plus (2TB M.2 NVME SSD)
- PSU
- n/a
- Mouse
- Wireless Mouse M510
- Internet Speed
- 2100Mbps/300Mbps
- Browser
- Firefox
- Antivirus
- Malwarebytes
-
At a glance
Windows 11 Pro 25H2 (26200.8246)AMD Ryzen 7 5700X3DG.SKILL Flare X 32GB (2x16GB) DDR4ASUS ROG-STRIX-RTX3060TI-08G-V2-GAMING (RTX 3...- Operating System
- Windows 11 Pro 25H2 (26200.8246)
- Computer type
- PC/Desktop
- Manufacturer/Model
- Custom build
- CPU
- AMD Ryzen 7 5700X3D
- Motherboard
- ASUS ROG Strix B550-F Gaming WiFi II
- Memory
- G.SKILL Flare X 32GB (2x16GB) DDR4
- Graphics card(s)
- ASUS ROG-STRIX-RTX3060TI-08G-V2-GAMING (RTX 3060-Ti, 8GB RAM)
- Monitor(s) Displays
- Samsung G50D IPS 27"
- Screen Resolution
- 1440p/180Hz
- Hard Drives
- SAMSUNG 990 EVO Plus (2TB] M.2 NVME SSD
SAMSUNG 990 EVO Plus (4TB) M.2 NVME SSD
- PSU
- Corsair RM750x (750 watts)
- Case
- Cooler Master MasterCase 5
- Cooling
- Scythe Mugen 6
- Keyboard
- Logitech K520 (MK540 keyboard/mouse combo)
- Mouse
- Logitech M310 (MK540 keyboard/mouse combo)
- Internet Speed
- 2100 Mbps down / 300 Mbps up
- Browser
- Firefox, Edge, Chrome
- Antivirus
- Malwarebytes (Premium)
- Other Info
- ASUS Blu-ray Burner BW-16D1HT (SATA) || Western Digital Easystore 20TB USB 3.0 external hard drive used with Acronis True Image 2025 backup software || HP OfficeJet Pro 6975 Printer/Scanner






