Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
319 commits
Select commit Hold shift + click to select a range
dcdb9cc
Update README.md
nopharshalom Sep 23, 2025
22c2fba
Update README.md
nopharshalom Sep 23, 2025
5d2498d
Update README.md
nopharshalom Sep 23, 2025
5ea6945
Merge branch 'IRL-CT:Fall2025' into Fall2025
nopharshalom Sep 24, 2025
c0359d5
organize readme
nopharshalom Sep 25, 2025
91ec0df
Update README.md
nopharshalom Sep 25, 2025
7eb0a9f
Update README.md
nopharshalom Sep 25, 2025
994da18
Add files via upload
nopharshalom Sep 25, 2025
7e534e0
Update README.md
nopharshalom Sep 25, 2025
0abe9ca
VERPLANK DIAGRAM LAB3
nopharshalom Sep 26, 2025
8f91559
Update README.md
nopharshalom Sep 26, 2025
4b41016
Update README.md
nopharshalom Sep 26, 2025
6e2d021
Update README.md
nopharshalom Sep 26, 2025
025d7e9
Update README.md
nopharshalom Sep 26, 2025
b3fb1a1
Update README.md
nopharshalom Sep 26, 2025
2e2b1a9
Update README.md
nopharshalom Sep 26, 2025
6104bad
Update README.md
nopharshalom Sep 27, 2025
245bab2
Add files via upload
nopharshalom Sep 28, 2025
73c6c26
add vid and desription
nopharshalom Sep 28, 2025
62bf2db
Update README.md
nopharshalom Sep 28, 2025
10a4a1f
Update README.md
nopharshalom Sep 28, 2025
5adf0be
Update README.md
nopharshalom Sep 28, 2025
af9009b
Update README.md
nopharshalom Sep 28, 2025
72601cd
Update README.md
nopharshalom Sep 29, 2025
0514093
Update README.md
nopharshalom Oct 1, 2025
e829fc4
Add files via upload
nopharshalom Oct 1, 2025
656cf50
Update README.md
nopharshalom Oct 1, 2025
3aa40df
Update README.md
nopharshalom Oct 1, 2025
2a831c7
Update README.md
nopharshalom Oct 1, 2025
9499ec0
Update README.md
nopharshalom Oct 1, 2025
6d312d1
Merge branch 'IRL-CT:Fall2025' into Fall2025
nopharshalom Oct 2, 2025
abcfec1
Update README.md
nopharshalom Oct 2, 2025
aea9935
Create mpr121samplecode
nopharshalom Oct 3, 2025
08cc8de
Add files via upload
nopharshalom Oct 4, 2025
a1acccc
planttalk
Alubeto Oct 4, 2025
c2884aa
Update PlantTalk.py
nopharshalom Oct 4, 2025
11497fc
Update PlantTalk.py
nopharshalom Oct 4, 2025
345f5f8
Add files via upload
nopharshalom Oct 4, 2025
d364125
Update README.md
nopharshalom Oct 4, 2025
e2db872
Update README.md
nopharshalom Oct 4, 2025
9eebb75
Update README.md
nopharshalom Oct 4, 2025
71027f6
Update README.md
nopharshalom Oct 4, 2025
911c079
Update README.md
nopharshalom Oct 4, 2025
d5d4ae4
Update README.md
nopharshalom Oct 4, 2025
ba31709
Update README.md
nopharshalom Oct 4, 2025
e6bb43c
Update README.md
nopharshalom Oct 4, 2025
27ca010
Update README.md
nopharshalom Oct 6, 2025
fe5f86a
Update README.md
nopharshalom Oct 6, 2025
32c9329
Update README.md
nopharshalom Oct 6, 2025
3bca827
Add files via upload
nopharshalom Oct 6, 2025
f8e0d0e
Update README.md
nopharshalom Oct 6, 2025
4961a36
Update README.md
nopharshalom Oct 6, 2025
50d7c36
Update README.md
nopharshalom Oct 6, 2025
b66ed16
Update README.md
nopharshalom Oct 6, 2025
6349ccc
Update README.md
nopharshalom Oct 7, 2025
1af620b
Update README.md
nopharshalom Oct 8, 2025
bbe9d2c
Update README.md
nopharshalom Oct 8, 2025
3db3dc7
Update README.md
nopharshalom Oct 8, 2025
b58b19a
Update README.md
nopharshalom Oct 8, 2025
06c59d2
Update README.md
nopharshalom Oct 8, 2025
fbee119
Add files via upload
nopharshalom Oct 8, 2025
8a5ac16
Update README.md
nopharshalom Oct 8, 2025
4ab8f94
Delete Lab 4/Screenshot 2025-10-08 184004.png
nopharshalom Oct 8, 2025
1bd60b2
Delete Lab 4/Screenshot 2025-10-08 183953.png
nopharshalom Oct 8, 2025
34dafd1
Delete Lab 4/Screenshot 2025-10-08 183942.png
nopharshalom Oct 8, 2025
faeb5cb
Delete Lab 4/Screenshot 2025-10-08 183931.png
nopharshalom Oct 8, 2025
b2a7831
Delete Lab 4/Screenshot 2025-10-08 183918.png
nopharshalom Oct 8, 2025
f3fe885
Delete Lab 4/Screenshot 2025-10-08 183910.png
nopharshalom Oct 8, 2025
703dfa7
Delete Lab 4/Screenshot 2025-10-08 183856.png
nopharshalom Oct 8, 2025
f28f877
Add files via upload
nopharshalom Oct 8, 2025
fbd6db6
Update README.md
nopharshalom Oct 8, 2025
ab6fd8d
Update README.md
nopharshalom Oct 8, 2025
1da74e2
Add files via upload
nopharshalom Oct 8, 2025
3a1ef34
Update README.md
nopharshalom Oct 8, 2025
29325fc
Update README.md
nopharshalom Oct 8, 2025
b2d952e
Update README.md
nopharshalom Oct 8, 2025
4debe6e
Update README.md
nopharshalom Oct 8, 2025
57ac12f
Update README.md
nopharshalom Oct 8, 2025
09c67c8
Update README.md
nopharshalom Oct 8, 2025
2badac5
Update README.md
nopharshalom Oct 8, 2025
7828180
Update README.md
nopharshalom Oct 8, 2025
2518a94
Update README.md
nopharshalom Oct 8, 2025
a60b031
Update README.md
nopharshalom Oct 8, 2025
878b969
Update README.md
nopharshalom Oct 8, 2025
51bffed
Add files via upload
nopharshalom Oct 15, 2025
c6502c7
Add video playback with proximity sensor control
nopharshalom Oct 15, 2025
f9e439a
Merge branch 'IRL-CT:Fall2025' into Fall2025
nopharshalom Oct 15, 2025
17362f7
update freeze dance to use rotary encoder
nopharshalom Oct 17, 2025
7e2348b
Refactor video download and rotary encoder logic
nopharshalom Oct 18, 2025
e5c71c9
Fix syntax error in sys.exit call
nopharshalom Oct 18, 2025
09181f4
Change Seesaw I2C address from 0x36 to 0x71
nopharshalom Oct 18, 2025
715ab67
Update freezedance.py
nopharshalom Oct 18, 2025
97ddc10
Comment out rotary encoder setup
nopharshalom Oct 18, 2025
ed4168d
Clean up unused code and update sensor message
nopharshalom Oct 18, 2025
d9f8e45
Update README.md
nopharshalom Oct 18, 2025
78c8936
Revise README with design iterations and reflections
nopharshalom Oct 18, 2025
0e1005f
Add files via upload
nopharshalom Oct 18, 2025
6f38d68
Fix image formatting in README.md
nopharshalom Oct 18, 2025
a7d8e64
Update README with multidevice code and formatting
nopharshalom Oct 18, 2025
4a6fee7
Add video demos to README for Part F
nopharshalom Oct 18, 2025
b9f47f7
Update video demo section formatting in README
nopharshalom Oct 18, 2025
ceeffef
Revise video demos section in README
nopharshalom Oct 18, 2025
04c8178
Add files via upload
nopharshalom Oct 19, 2025
f5dbf19
Update README with Illustrator file image
nopharshalom Oct 19, 2025
afbe152
Revise written reflection for clarity and detail
nopharshalom Oct 19, 2025
99ab19c
Implement disco function for LED effects
nopharshalom Oct 19, 2025
043dfc3
Remove unnecessary newline in freezedance.py
nopharshalom Oct 19, 2025
5e7b20b
Refactor LED control and improve video playback logic
nopharshalom Oct 19, 2025
2ed5025
Refactor GPIO control and add video download feature
nopharshalom Oct 19, 2025
e69be29
Integrate Qwiic GPIO for LED control and motion detection
nopharshalom Oct 19, 2025
e16ab8f
Fix VLC player position reset on clip end
nopharshalom Oct 19, 2025
3a41eec
Refactor and improve code clarity in freezedance.py
nopharshalom Oct 19, 2025
76d3bee
Refactor to support YouTube playlist and GPIO updates
nopharshalom Oct 19, 2025
8d2669c
Refactor to use MPR121 for touch control and volume
nopharshalom Oct 19, 2025
a706ba4
Create placeholdertext.txt
nopharshalom Oct 19, 2025
0393343
Add files via upload
nopharshalom Oct 19, 2025
2b5e52c
Replace VLC with Pygame for music playback
nopharshalom Oct 19, 2025
d26900f
Refactor sensor setup and enhance music controls
nopharshalom Oct 19, 2025
e7e3b12
Update freezedance.py
nopharshalom Oct 19, 2025
25ff5a7
Replace qwiic with adafruit_mpr121 import
nopharshalom Oct 19, 2025
33b2aba
Update freezedance.py
nopharshalom Oct 19, 2025
5f0959e
Update freezedance.py
nopharshalom Oct 19, 2025
6953006
Change sensor initialization from VCNL4040 to VL53L1X
nopharshalom Oct 19, 2025
ee10de0
Update MPR121 import to use adafruit library
nopharshalom Oct 19, 2025
df2d812
Add I2C initialization for sensors
nopharshalom Oct 19, 2025
bc93edc
Simplify sensor initialization by removing checks
nopharshalom Oct 19, 2025
aef7ab8
Fix sensor initialization for vcnl4040
nopharshalom Oct 19, 2025
ecbfb36
Enhance user feedback and code comments
nopharshalom Oct 19, 2025
45f39cc
Fix sensor initialization check for VL53L1X
nopharshalom Oct 19, 2025
0df9a1e
Fix sensor initialization check for VCNL4040
nopharshalom Oct 19, 2025
1f5d726
Update freezedance.py
nopharshalom Oct 19, 2025
ac24b29
Update freezedance.py
nopharshalom Oct 19, 2025
9e78b59
Fix print statements for consistency
nopharshalom Oct 19, 2025
414acb5
Update freezedance.py
nopharshalom Oct 19, 2025
f61a66d
Add delay for VL53L1X sensor initialization
nopharshalom Oct 19, 2025
ff89c5b
Add error handling for sensor initialization
nopharshalom Oct 19, 2025
96270e0
Increase sensor power-up delay from 0.05s to 0.1s
nopharshalom Oct 19, 2025
c143f17
Disable VL53L1X sensor initialization
nopharshalom Oct 19, 2025
6a05c3f
Update freezedance.py
nopharshalom Oct 19, 2025
7e35fe7
Revise README to document system updates and features
nopharshalom Oct 19, 2025
57527f1
Add files via upload
nopharshalom Oct 19, 2025
208ba64
Add files via upload
nopharshalom Oct 19, 2025
1484c03
Update README.md
nopharshalom Oct 19, 2025
8f38c8d
Merge branch 'IRL-CT:Fall2025' into Fall2025
nopharshalom Oct 20, 2025
e84735a
Add files via upload
nopharshalom Oct 23, 2025
36b6820
Update README with lab details and object recognition
nopharshalom Oct 23, 2025
71cfb63
Fix image filename in README
nopharshalom Oct 23, 2025
3315a35
Update README.md
nopharshalom Oct 23, 2025
b3e7a36
Revise README for demo videos and section titles
nopharshalom Oct 23, 2025
08c1d7a
Add demo video links to README
nopharshalom Oct 23, 2025
95195cb
Update video section headers in README.md
nopharshalom Oct 23, 2025
2103149
Revise README for Part A and demo videos
nopharshalom Oct 23, 2025
76bd721
Update README.md
nopharshalom Oct 23, 2025
ce88ed7
Separate Quiet Coyote and Pinch Demo Video sections
nopharshalom Oct 23, 2025
b1e2b97
Revise section headers in README.md
nopharshalom Oct 23, 2025
5703351
Format section headers for consistency
nopharshalom Oct 23, 2025
dfddba7
Update .gitignore to include .venv files
nopharshalom Oct 26, 2025
b6691e9
Add files via upload
nopharshalom Oct 26, 2025
b63940a
Add files via upload
nopharshalom Oct 26, 2025
5a18535
Add files via upload
nopharshalom Oct 26, 2025
411beb2
Update README with Teachable Machine resources
nopharshalom Oct 26, 2025
288dc44
Fix link to model.tflite file in README
nopharshalom Oct 26, 2025
3f1b244
Document coffee line detector interaction in README
nopharshalom Oct 26, 2025
8b3390f
Add files via upload
nopharshalom Oct 26, 2025
055f2fd
Add example frames for coffee line detector
nopharshalom Oct 26, 2025
f52174d
Refine coffee line detection project details
nopharshalom Oct 26, 2025
bb249ba
Update README.md to improve section formatting
nopharshalom Oct 26, 2025
0641b0f
Update README.md
nopharshalom Oct 26, 2025
308646d
Create placeholder.txt
nopharshalom Oct 26, 2025
5bbfb32
Add line detection for coffee using Teachable Machine
nopharshalom Oct 26, 2025
0e784b3
Add files via upload
nopharshalom Oct 26, 2025
8487b70
Refactor lineforcoffee.py for new image and predictions
nopharshalom Oct 26, 2025
2572c70
Update lineforcoffee.py
nopharshalom Oct 26, 2025
77995bd
Add files via upload
nopharshalom Oct 26, 2025
152b270
Fix typo in README for Part C instructions
nopharshalom Oct 26, 2025
c971049
Add files via upload
nopharshalom Oct 26, 2025
6cfd2ec
Add images to README for Part C documentation
nopharshalom Oct 26, 2025
9333493
Add files via upload
nopharshalom Oct 26, 2025
1e71297
Update README.md
nopharshalom Oct 26, 2025
6c09f8b
Fix numbering and enhance clarity in README
nopharshalom Oct 26, 2025
8fb247f
Enhance title for coffee line detection section
nopharshalom Oct 26, 2025
41423cb
Revise observation notes in README.md
nopharshalom Oct 26, 2025
71ffd37
Fix image tag for Line for Coffee fault GIF
nopharshalom Oct 26, 2025
b2ad5a5
Add files via upload
nopharshalom Oct 26, 2025
e807451
Create songsplitter.py
nopharshalom Oct 28, 2025
84b9046
Create placeholder.txt
nopharshalom Oct 28, 2025
b5eee43
Add files via upload
nopharshalom Oct 28, 2025
4250002
Add files via upload
nopharshalom Oct 28, 2025
7b6255a
Create placeholder.txt
nopharshalom Oct 28, 2025
bd501b5
Add files via upload
nopharshalom Oct 28, 2025
9c2e3b8
Add files via upload
nopharshalom Oct 28, 2025
1750d19
Create placeholder.txt
nopharshalom Oct 28, 2025
c842f58
Add files via upload
nopharshalom Oct 28, 2025
f21c296
Add files via upload
nopharshalom Oct 28, 2025
85f8c70
Create placeholder.txt
nopharshalom Oct 28, 2025
b92348e
Add files via upload
nopharshalom Oct 28, 2025
f31beb4
Add files via upload
nopharshalom Oct 28, 2025
1f25f64
Create placeholder.txt
nopharshalom Oct 28, 2025
15ead53
Add files via upload
nopharshalom Oct 28, 2025
8b0bf21
Add files via upload
nopharshalom Oct 28, 2025
001d408
Create HandTrackingModule.py
nopharshalom Oct 28, 2025
9ae5829
Refactor handDetector initialization parameters
nopharshalom Oct 29, 2025
61d4e6f
Update songsplitter.py
nopharshalom Oct 29, 2025
11d326a
Refactor song playback to use pygame mixer
nopharshalom Oct 29, 2025
fb19d9d
Enhance song loading and mute state management
nopharshalom Oct 29, 2025
c8674f0
Refactor comments and adjust fist detection logic
nopharshalom Oct 29, 2025
0e51e2d
Document GestureTrack system characteristics
nopharshalom Oct 29, 2025
da5be1f
Enhance README with GestureTrack system details
nopharshalom Oct 29, 2025
18410cf
Update README with demo videos and descriptions
nopharshalom Oct 29, 2025
0c2bbc1
Add files via upload
nopharshalom Oct 29, 2025
ca56783
Expand README with GestureTrack details and usage
nopharshalom Oct 29, 2025
29026df
Update README.md
nopharshalom Oct 29, 2025
44992c7
Enhance README with emoji headers
nopharshalom Oct 29, 2025
1c6f9bb
Revise README with gesture tracking information
nopharshalom Oct 29, 2025
66aae1d
Update README with GestureTrack usage details
nopharshalom Oct 29, 2025
59c9c92
Add creator information to README
nopharshalom Oct 29, 2025
0be684e
Enhance README with coding process and tools used
nopharshalom Oct 29, 2025
7367748
Added Lab 6
nopharshalom Nov 4, 2025
c67073f
Add BirdCounterGame.py for MQTT-based game
nopharshalom Nov 5, 2025
71dc31b
Revise README for Lab 6 with project information
nopharshalom Nov 5, 2025
5f19df9
Add StudentCounterGame.py file
nopharshalom Nov 5, 2025
a672f7d
Update StudentCounterGame.py
nopharshalom Nov 5, 2025
250911b
Update README.md
nopharshalom Nov 8, 2025
b28ce71
Update README.md
nopharshalom Nov 9, 2025
05310a5
Add files via upload
nopharshalom Nov 9, 2025
f998beb
Update README.md
nopharshalom Nov 9, 2025
2792d90
Add files via upload
nopharshalom Nov 9, 2025
c983a8f
Update README.md
nopharshalom Nov 9, 2025
74e0d48
Add files via upload
nopharshalom Nov 9, 2025
19e600a
Update README.md
nopharshalom Nov 9, 2025
f86395a
Update README.md
nopharshalom Nov 9, 2025
c975f07
Add files via upload
nopharshalom Nov 9, 2025
271b07e
Update README.md
nopharshalom Nov 9, 2025
c11d8f6
Update README.md
nopharshalom Nov 17, 2025
ad579db
Add QR Scanner with ST7789 display and laptop control
nopharshalom Dec 4, 2025
b2f392a
Create README.md
nopharshalom Dec 4, 2025
0309c1a
Enhance README with project details and documentation
nopharshalom Dec 15, 2025
1fa1931
Add camera_find.py to test video devices
nopharshalom Dec 15, 2025
9895c60
Add .cache file with access token details
nopharshalom Dec 15, 2025
88ececd
Add Raspberry Pi QR Scanner with LED and Display
nopharshalom Dec 15, 2025
724db5c
Add Flask server to handle play commands
nopharshalom Dec 15, 2025
50f8439
Add LED control script for Raspberry Pi
nopharshalom Dec 15, 2025
e82b975
Add dependencies to requirements.txt
nopharshalom Dec 15, 2025
240130d
Modify image widths and update video link
nopharshalom Dec 15, 2025
20a85fc
Fix image formatting in README.md
nopharshalom Dec 15, 2025
fe8d06e
Adjust image size and clarify code file locations
nopharshalom Dec 15, 2025
6cc6b38
Update Google Drive links in README.md
nopharshalom Dec 15, 2025
b8f0d92
Update collaborator information in README
nopharshalom Dec 15, 2025
811b6c6
Fix video links in README
nopharshalom Dec 24, 2025
23efd13
Update README with demo feedback
nopharshalom Dec 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
*.tflite
*.scorer
venv
venv*
__*
.venv*
.venv/
1 change: 1 addition & 0 deletions FinalProject/.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"access_token": "BQDp64oQLfHeqILGjX3hm_73BVmn7Awt-Qqzf2H4O5dQSkt6t1dZa-DYlYVYuhYZsu2QbgxCH_X8IIXaWoqafnGjfflPi3_deA3ppcVvJpjrwyUhOFEOAORUci8Is_a6qgxcBo45p7o", "token_type": "Bearer", "expires_in": 3600, "expires_at": 1764624520}
374 changes: 374 additions & 0 deletions FinalProject/README.md

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions FinalProject/camera_find.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import cv2

print("Testing video devices 0 through 40...")
for index in range(40):
cap = cv2.VideoCapture(index, cv2.CAP_V4L2)
if cap.isOpened():
ret, frame = cap.read()
if ret:
print(f"Working camera found at index {index}")
else:
print(f"Camera opened but no frames at index {index}")
cap.release()
257 changes: 257 additions & 0 deletions FinalProject/final.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
"""
Raspberry Pi 5 QR Scanner + ST7789 Display + Laptop Control
"""

import time
import digitalio
import board
import requests
import cv2
from pyzbar.pyzbar import decode
from PIL import Image, ImageOps
import io

import numpy as np
from sklearn.cluster import KMeans

# --- DISPLAY LIBRARIES ---
from adafruit_rgb_display.rgb import color565
import adafruit_rgb_display.st7789 as st7789

# ==========================================
# 1. HARDWARE SETUP (From your example)
# ==========================================

# Configuration for CS pin (GPIO5/Pin 29)
cs_pin = digitalio.DigitalInOut(board.D5)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = None
BAUDRATE = 64000000

# Setup SPI
spi = board.SPI()

# Setup Display
display = st7789.ST7789(
spi,
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
width=135,
height=240,
x_offset=53,
y_offset=40,
# rotation=90 # You might need to uncomment this if the image is sideways
)

# Setup Backlight
backlight = digitalio.DigitalInOut(board.D22)
backlight.switch_to_output(value=True)

# ==========================================
# 2. CONFIGURATION
# ==========================================
LAPTOP_IP = "10.56.3.68" # <--- UPDATE THIS TO YOUR LAPTOP IP
LAPTOP_PORT = "5002"
RESET_TIME = 6000

# ==========================================
# 3. HELPER FUNCTIONS
# ==========================================

def get_youtube_thumbnail(url):
"""
Downloads YouTube thumbnail and converts it to a PIL Image
that fits the ST7789 screen.
"""
video_id = ""
if "v=" in url:
try:
video_id = url.split("v=")[1].split("&")[0]
except: pass
elif "youtu.be/" in url:
try:
video_id = url.split("youtu.be/")[1].split("?")[0]
except: pass

if not video_id:
return None

# Download High Quality Thumb
thumb_url = f"https://img.youtube.com/vi/{video_id}/hqdefault.jpg"
print(f"Downloading art: {thumb_url}")

try:
resp = requests.get(thumb_url, timeout=2)
if resp.status_code == 200:
# Convert bytes to PIL Image
image = Image.open(io.BytesIO(resp.content))

# Resize and Crop to fit the screen dimensions
# We use the display.width and display.height so it fits your config
image = ImageOps.fit(image, (display.width, display.height), method=Image.LANCZOS)
return image
except Exception as e:
print(f"Image download failed: {e}")

return None

def extract_primary_colors(image, num_colors=3):
"""
Given a PIL Image, returns `num_colors` dominant colors as RGB tuples.
Uses k-means clustering on all pixels.
"""
# Convert image to numpy array
img = image.convert("RGB")
img_np = np.array(img)

# Flatten pixel array into (num_pixels, 3)
pixels = img_np.reshape(-1, 3)

# KMeans clustering
kmeans = KMeans(n_clusters=num_colors, n_init="auto")
kmeans.fit(pixels)

# Cluster centers are the dominant colors
colors = kmeans.cluster_centers_.astype(int)

# Convert to list of (R, G, B)
return [tuple(color) for color in colors]

# ============================
# LED STRIP SETUP
# ============================
import neopixel_spi as neopixel

NUM_PIXELS = 100
PIXEL_ORDER = neopixel.RGB
BRIGHTNESS = 0.3

spi_led = board.SPI() # LED strip also uses SPI

pixels = neopixel.NeoPixel_SPI(
spi_led,
NUM_PIXELS,
pixel_order=PIXEL_ORDER,
brightness=BRIGHTNESS,
auto_write=False
)


def dominant_color_cycle(colors, wait=0.05, repeat=2):
"""
Animate the LED strip using a list of dominant (R, G, B) colors.
- colors: list of RGB tuples [(r,g,b), (r,g,b), ...]
- wait: delay between LED updates
- repeat: how many times to sweep the strip per color
"""
if not colors:
print("No dominant colors provided.")
return

print("Animating dominant colors:", colors)

for color in colors:
r, g, b = color
print(f"Color wipe: {str(color[0]), str(color[1]), str(color[2])}")

for _ in range(repeat):
for i in range(NUM_PIXELS):
pixels[i] = (r, g, b)
pixels.show()
time.sleep(wait)

def show_status_color(r, g, b):
"""Fills screen with a solid color"""
display.fill(color565(r, g, b))

# ==========================================
# 4. MAIN LOOP
# ==========================================

def main():
print("Starting Webcam...")
cap = cv2.VideoCapture(0)

if not cap.isOpened():
print("Error: Webcam not found.")
return

print("Scanner Running. Waiting for QR codes...")

# Flash blue to show it's ready
show_status_color(0, 0, 255)
time.sleep(0.5)
show_status_color(0, 0, 0) # Clear to black

last_played_link = None
last_seen_time = 0

try:
while True:
# Read frame
ret, frame = cap.read()
if not ret:
break

qr_codes = decode(frame)

# Reset logic: If no code seen for RESET_TIME, allow rescanning
if not qr_codes:
if last_played_link is not None and (time.time() - last_seen_time > RESET_TIME):
print("Resetting... Ready for new code.")
last_played_link = None
show_status_color(0, 0, 0) # Clear screen to black when reset

for code in qr_codes:
link = code.data.decode('utf-8')
last_seen_time = time.time()

if link != last_played_link:
print("-" * 30)
print(f"Found: {link}")

# 1. Show YELLOW while processing
show_status_color(255, 255, 0)

# 2. Send to Laptop
try:
requests.get(f"http://{LAPTOP_IP}:{LAPTOP_PORT}/play", params={'url': link}, timeout=1)
print("Sent to laptop.")
except:
print("Could not connect to laptop.")

# 3. Get Album Art
art_image = get_youtube_thumbnail(link)

# 4. Display Art
if art_image:
display.image(art_image)

# ---- Extract Colors ----
dominant_colors = extract_primary_colors(art_image, num_colors=3)
print("Dominant Colors:", dominant_colors)

# ---- Run LED animation ----
dominant_color_cycle(dominant_colors)

else:
# If no art found, show RED, then Black
show_status_color(255, 0, 0)
time.sleep(1)
show_status_color(0, 0, 0)

last_played_link = link

# Small sleep to save CPU
time.sleep(0.1)

except KeyboardInterrupt:
print("\nStopping...")
backlight.value = False # Turn off screen
finally:
cap.release()

if __name__ == '__main__':
main()
23 changes: 23 additions & 0 deletions FinalProject/final_project_code_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask import Flask, request
import webbrowser
import os

app = Flask(__name__)

@app.route('/play', methods=['GET'])
def play():
# Get the link sent from the Pi
link = request.args.get('url')

if link:
print(f"Received command to play: {link}")
# Open the link in your default browser (Chrome/Safari/Edge)
webbrowser.open(link)
return "Command Received: Playing!"
else:
return "Error: No URL provided."

if __name__ == '__main__':
# '0.0.0.0' allows other devices (like the Pi) to talk to this laptop
print("Laptop Listener Active! Waiting for Pi...")
app.run(host='0.0.0.0', port=5001)
69 changes: 69 additions & 0 deletions FinalProject/led_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from rpi_ws281x import PixelStrip, Color
import time

# LED strip configuration:
LED_COUNT = 30 # Number of LEDs
LED_PIN = 18 # GPIO pin (must support PWM!)
LED_FREQ_HZ = 800000 # LED signal frequency (800kHz WS2812)
LED_DMA = 10 # DMA channel
LED_BRIGHTNESS = 50 # 0-255
LED_INVERT = False
LED_CHANNEL = 0 # Use channel 0 for GPIO18
LED_STRIP_TYPE = None # Auto-detect

# Create the strip object
strip = PixelStrip(
LED_COUNT,
LED_PIN,
LED_FREQ_HZ,
LED_DMA,
LED_INVERT,
LED_BRIGHTNESS,
LED_CHANNEL,
LED_STRIP_TYPE
)

strip.begin()

def color_wipe(color, wait_ms=50):
"""Wipe color across display."""
for i in range(strip.numPixels()):
strip.setPixelColor(i, color)
strip.show()
time.sleep(wait_ms / 1000.0)

def rainbow_cycle(wait_ms=10):
for j in range(256):
for i in range(strip.numPixels()):
strip.setPixelColor(i, wheel((i * 256 // strip.numPixels() + j) & 255))
strip.show()
time.sleep(wait_ms / 1000.0)

def wheel(pos):
"""Generate colors across a spectrum."""
if pos < 85:
return Color(pos * 3, 255 - pos * 3, 0)
elif pos < 170:
pos -= 85
return Color(255 - pos * 3, 0, pos * 3)
else:
pos -= 170
return Color(0, pos * 3, 255 - pos * 3)

def main():
print("Testing LED strip...")
try:
while True:
color_wipe(Color(255, 0, 0)) # Red
color_wipe(Color(0, 255, 0)) # Green
color_wipe(Color(0, 0, 255)) # Blue
rainbow_cycle()
except KeyboardInterrupt:
strip.begin()
for i in range(strip.numPixels()):
strip.setPixelColor(i, Color(0, 0, 0))
strip.show()
print("LEDs off.")

if __name__ == "__main__":
main()
8 changes: 8 additions & 0 deletions FinalProject/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
spotipy
python-vlc
requests
Pillow
adafruit-blinka
adafruit-circuitpython-rgb-display
opencv-python
pyzbar
Empty file added Lab 2/.screen_clock.py.swp
Empty file.
Binary file added Lab 2/10piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/11piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/12piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/1piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/2piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/3piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/4piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/5piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/6piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/7piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/8piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/9piano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/Musicografi.ttf
Binary file not shown.
Binary file added Lab 2/PXL_20250920_192630500.MP.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/PXL_20250920_192641686.MP.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/PXL_20250920_192643997.MP.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Lab 2/PXL_20250922_214321453.MP.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading