Skip to content

Instantly share code, notes, and snippets.

# The basics of writing Python games
# See Game Development in Python 3 With PyGame on YouTube
import pygame
import time
import random
pygame.init()
pygame.key.set_repeat(50, 50) #So that when you hold a key down, it repeats
display_width = 800
display_height = 445
pause = False
@kcranley1
kcranley1 / LighthouseSequence.ino
Last active May 19, 2016 09:52
A method of achieving control of individual LEDs connected to the Arduino utputs
// Written by Adafruit. https://learn.adafruit.com/multi-tasking-the-arduino-part-1/a-classy-solution
// Modified by S&S
// A method of achieving control of individual LEDs connected to the Arduino outputs
//
class Flasher
{
// Class Member Variables
// These are initialized at startup
int ledPin; // the number of the LED pin
long OnTime; // milliseconds of on-time
@kcranley1
kcranley1 / 4d7sCommonAnode.py
Last active November 22, 2015 12:12
S&S's version for a common ANODE 7-segment display driven by Raspberry Pi
# S&S's version for a common ANODE 7-segment display driven by Raspberry Pi
# code modified, tweaked and tailored from code by bertwert
# on RPi forum thread topic 91796
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
# GPIO ports for the 7seg pins
segments = (11,4,23,8,7,10,18,25)
# 7seg_segment_pins (14,16,13,3,5,11,15,7) + 670R inline
@kcranley1
kcranley1 / 4d7sCommonCathode.py
Last active November 22, 2015 10:29
4-digit 7-segment COMMON CATHODE display driven by Raspberry Pi B+
# 4-digit 7-segment COMMON CATHODE display driven by Raspberry Pi B+
# code modified, tweaked and tailored from code by bertwert
# on RPi forum thread topic 91796
# and fiddled with a bit more by S&S
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
# GPIO ports for the 7seg pins
segments = (11,4,23,8,7,10,18,25)
@kcranley1
kcranley1 / KCledOrient.py
Created October 1, 2015 11:25
KC Python script to indicate roll & pitch on the Sense HAT LED array
#!/usr/bin/python3
from sense_hat import SenseHat
sense = SenseHat()
sense.clear()
old_x = old_y = 0
while True:
o = sense.get_orientation()
pitch = o["pitch"]
#!/usr/bin/python3
from sense_hat import SenseHat
import math
import pi3d
sense = SenseHat()
display = pi3d.Display.create()
cam = pi3d.Camera.instance()
//RasPiO Duino RGB color fading Mood Light NOW WITH LIGHT SENSING CAPABILITIES!!!
const int redPin = 11;
const int grnPin = 10;
const int bluPin = 9;
const int sensor = 3;
void setup()
{
@kcranley1
kcranley1 / astro_pi2.py
Created September 9, 2015 16:42
Python script for the Raspberry Pi Sense Hat which displays an image observed by the RasPiCam on the RGB LED array and also on the Pi's monitor.
import picamera
from picamera import PiCamera
from picamera.array import PiRGBArray
from sense_hat import SenseHat
sense = SenseHat()
camera = picamera.PiCamera()
def preview():
@kcranley1
kcranley1 / workshop.py
Last active April 27, 2024 08:16
A GUI program for use with the Raspberry Pi Camera
from Tkinter import *
import time
import picamera
import RPi.GPIO as GPIO
import numpy as np
import io
from datetime import datetime, timedelta
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
# GPIO GUI by S&S 5-Apr-15
from Tkinter import *
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)