Skip to content

Instantly share code, notes, and snippets.

View omiq's full-sized avatar

Chris Garrett omiq

View GitHub Profile
@omiq
omiq / pi-game-pad.py
Created April 12, 2018 23:14
Simple example of controlling a Pi using a game pad using python
from evdev import InputDevice
# create object to read input - specify YOUR device
controller = InputDevice('/dev/input/event0')
# want to display ALL info?
debug = False
# what are the controller details?
print(controller)
@omiq
omiq / camera.py
Created April 9, 2018 01:40
Simple digital camera using the TFT Hat from Adafruit
import os
import picamera
import gpiozero
from gpiozero import Button
import time
import datetime
from time import sleep
camera = picamera.PiCamera()
button = Button(23)
@omiq
omiq / gpio.py
Created April 5, 2018 19:52
Basic Pi GPIO example
import RPi.GPIO as GPIO
import time
# Pi has (confusingly) two numbering schemes for pins
# usually you would choose based on what is printed on
# your dongles/pinout prints
GPIO.setmode(GPIO.BCM)
# H-Bridge pins
@omiq
omiq / shooter.py
Created April 4, 2018 17:43
In this demno of the Python Arcade library, I demonstrate moving backgrounds, sprites, sound effects (now working with zero lag!), and scoring.
import random
import arcade
import _thread
class Fireball(arcade.Sprite):
def update(self):
move_rate = 10
self.center_y += move_rate
@omiq
omiq / arcade1.py
Created April 3, 2018 23:00
In this simple demo we bounce a sprite over a moving background to show the basic functions of the Python Arcade module
# https://makerhacks.com
import subprocess
import arcade
# Open the window. Set the window title and dimensions (width and height)
arcade.open_window(800, 600, "Drawing Test")
arcade.set_background_color(arcade.color.BLACK)
@omiq
omiq / cam.py
Created April 2, 2018 23:17
Simple cam.jpg display
#!/usr/bin/python3
import cgi
import cgitb
cgitb.enable()
print("Content-Type: text/html\n\n")
print("""
<html><head><title>CatCam</title>
<meta charset="utf-8">
@omiq
omiq / cam.sh
Last active April 2, 2018 23:35
Very simple BASH webcam script
#!/bin/bash
while [ 1 ];
do
raspistill -o cam.jpg
scp cam.jpg chrisg@example.com:apache/html/cam
sleep 5s
done
@omiq
omiq / qrscan.py
Created April 2, 2018 01:43
This version of the QRCode demo also displays on screen
import PIL
from PIL import Image
import pyzbar.pyzbar as pyzbar
import pygame
import pygame.camera
from pygame.locals import *
# set up the camera
pygame.init()
pygame.camera.init()
@omiq
omiq / qrscan.py
Created April 2, 2018 00:23
Demo of a QR scanner that repeatedly scans and looks for QR codes
import PIL
from PIL import Image
import pyzbar.pyzbar as pyzbar
import pygame
import pygame.camera
from pygame.locals import *
# set up the camera
pygame.init()
pygame.camera.init()
@omiq
omiq / serial.c
Created March 27, 2018 23:38
Arduino example of listening for strings over serial
#include <Wire.h>
#include <I2C_LCD.h>
I2C_LCD LCD;
extern GUI_Bitmap_t bmlogo; //Declare bitmap data package.
uint8_t I2C_LCD_ADDRESS = 0x51; //Device address configuration, the default value is 0x51.
String instring;
void setup(void)