Skip to content

Instantly share code, notes, and snippets.

@frogwoo
frogwoo / lineSensor.py
Last active January 8, 2017 18:08
Simple code to read values from an analogue line sensor (using an ADC as this is for the Pi) and say if a line is detected or not. View https://theraspberryblonde.wordpress.com/2017/01/08/qre1113-analogue-line-sensor-with-raspberry-pi/ to see more details about how to use the code.
#!/usr/bin/python
import spidev
import time
# which ADC input the sensor is connected to
sensor = 0
# the boundary between no line detected and a line detected
boundary = 30
@frogwoo
frogwoo / sound.pde
Created September 6, 2016 14:16
Code for music visualisation on the Pi-Lite with Processing
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
import processing.serial.*;
Serial port;
String portID = "/dev/ttyAMA0";
@frogwoo
frogwoo / pilite.pde
Created August 30, 2016 21:22
An example for controlling the Pi-Lite with Processing
import processing.serial.*;
Serial port;
String portID = "/dev/ttyAMA0";
int squareSize = 80;
int[] colColours = {#061A07,#072409,#0F4812,#136A18,#198B20,#1DA724,#20C629,#36FF41};
int[] colLengths = {9,8,7,6,5,4,3,2};
int selectedCol = 3;
@frogwoo
frogwoo / basicpilite.pde
Created August 30, 2016 20:19
Simple control of the Pi-Lite HAT with Processing
import processing.serial.*;
Serial port;
String portID = "/dev/ttyAMA0";
void setup() {
size(100,100);
background(255)
port = new Serial(this,portID,9600);
}
import processing.io.*;
boolean ledStatus = false;
int rectX = 50;
int rectY = 50;
int rectW = 200;
int fillCol;
void setup() {
size(300,300);
import pygame, sys
from time import sleep
# setup the pygame window
pygame.init()
window = pygame.display.set_mode((200, 200), 0, 32)
# how many joysticks connected to computer?
joystick_count = pygame.joystick.get_count()
print "There is " + str(joystick_count) + " joystick/s"