Skip to content

Instantly share code, notes, and snippets.

@theapi
theapi / shift_register.c
Created January 27, 2014 19:30
Attiny85 avr-c shift register 74HC595
//#define F_CPU 16000000L
#include <avr/io.h>
#include <util/delay.h>
#define PIN_DATA PB0 // DS
#define PIN_CLOCK PB1 // SH_CP
#define PIN_LATCH PB2 // ST_CP
// From Android.h
@theapi
theapi / ws_joystick.html
Last active May 31, 2022 16:02
Websocket with the virtual joystick Uses WebSocket-for-Python (CherryPy) & https://github.com/jeromeetienne/virtualjoystick.js
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script type='application/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
<script type='application/javascript'>
$(document).ready(function() {
@theapi
theapi / knock.py
Last active November 27, 2018 01:11
Simple demo to detect knocking from a piezo sensor on the Raspberry Pi.
#!/usr/bin/python
import time, signal, sys
from Adafruit_ADS1x15 import ADS1x15
def signal_handler(signal, frame):
print 'You pressed Ctrl+C!'
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
#print 'Press Ctrl+C to exit'
// spi.c
//
// Example program for bcm2835 library
// Shows how to interface with SPI to transfer a byte to and from an SPI device
//
// After installing bcm2835, you can build this
// with something like:
// gcc -o spi spi.c -l bcm2835
// sudo ./spi
//
@theapi
theapi / blinkc_nodelay.c
Last active January 3, 2016 22:49
Port manipulation using a timer interrupt instead of delay
/*
* main.c
* ATmega328p port manipulation
*/
/********************************************************************************
Includes
********************************************************************************/
#include <avr/io.h>
@theapi
theapi / blinkc.c
Created January 20, 2014 13:20
Port manipulation in avr-c
/*
* main.c
*
* Created on: 19 Jan 2014
* Author: peter
*/
//#define F_CPU 16000000L
#include <avr/io.h>
#include <util/delay.h>
@theapi
theapi / blink.c
Created January 19, 2014 18:34
The hello world of avr-c
@theapi
theapi / ping_new.ino
Last active January 2, 2016 04:59
2 ping sensors with ir transmitter
#include <NewPing.h>
#include <VirtualWire.h>
#define RF_TX_PIN 9 // Pin 12 is the default sender pin so change it here.
#define SONAR_NUM 2 // Number of sensors.
#define MAX_DISTANCE 500 // Maximum distance (in cm) to ping.
#define PING_INTERVAL 33 // Milliseconds between sensor pings (29ms is about the min to avoid cross-sensor echo).
@theapi
theapi / pygame_ps3.py
Created December 24, 2013 23:16
PS3 two axis reading
import pygame
from pygame.locals import *
class App:
def __init__(self):
pygame.init()
pygame.display.set_caption("Joystick Analyzer")
# Set up the joystick
@theapi
theapi / baby_steps.ino
Created December 15, 2013 20:22
baby_steps.ino backup
// https://github.com/netlabtoolkit/VarSpeedServo
#include <VarSpeedServo.h>
#define LEFT_ANKLE_CENTRE 90
//Servo servo;
VarSpeedServo LeftHip;
VarSpeedServo LeftAnkle;