Skip to content

Instantly share code, notes, and snippets.

View lesp's full-sized avatar
🏠
Working from home

Les lesp

🏠
Working from home
View GitHub Profile
@lesp
lesp / GPIO-Blink.py
Last active June 2, 2016 13:50
Example code to show how to flash an LED attached to pin 17 on a Raspberry Pi
@lesp
lesp / Install
Created April 28, 2016 12:47
Install the Python wrapper
sudo python setup.py install
cd python
@lesp
lesp / clone
Created April 28, 2016 12:46
Clone and change directory
git clone https://github.com/jgarff/rpi_ws281x.git
cd
scons
@lesp
lesp / install
Created April 28, 2016 12:44
Install new software
sudo apt-get install build-essential python-dev git scons swig
@lesp
lesp / update
Created April 28, 2016 12:44
Update software repo on Pi
sudo apt-get update
@lesp
lesp / pymon.py
Created April 28, 2016 12:41
Complete code listing
from neopixel import *
from gpiozero import Button
from time import sleep
import random
green = Button(4)
pink = Button(17)
yellow = Button(27)
blue = Button(22)
@lesp
lesp / pymon.py
Created April 28, 2016 12:32
Error handling
except KeyboardInterrupt:
for i in range(360):
strip.setPixelColor(i,Color(0,0,0))
strip.show()
@lesp
lesp / pymon.py
Created April 28, 2016 12:31
checking the sequence against the users choice
if lights == player:
print("CORRECT")
correct(0.1)
for i in range(150):
strip.setPixelColor(i,Color(0,0,0))
strip.show()
else:
print("WRONG ANSWER McFLY")
wrong(0.1)
for i in range(150):
@lesp
lesp / pymon.py
Created April 28, 2016 12:30
check for player button presses
while len(player) <4:
sleep(0.3)
if green.is_pressed:
player.append("green")
neo("green",0.1)
print(player)
elif pink.is_pressed:
player.append("pink")
neo("pink",0.1)
print(player)