Skip to content

Instantly share code, notes, and snippets.

@silbo
silbo / rudolph.ino
Last active September 6, 2018 22:55
Rudolph
/* Play Melody
* -----------
*
* Program to play a simple melody
*
* Tones are created by quickly pulsing a speaker on and off
* using PWM, to create signature frequencies.
*
* Each note has a frequency, created by varying the period of
* vibration, measured in microseconds. We'll use pulse-width
@silbo
silbo / buzzer.ino
Last active August 17, 2018 10:11
Piezzo buzzer and ultrasonic sensor
// Add ultrasonic distance sensor library
#include <NewPing.h>
// Disntance sensor
static const int echo_pin = 2;
static const int trigger_pin = 3;
static const int max_distance = 200;
// Piezzo buzzer
static const int piezo_pin = 11;
@silbo
silbo / AD7173.ino
Last active January 15, 2016 18:42
AD7173 test
/*
====================
AD7173 ADC test code
====================
*/
#include <SPI.h>
void print_byte(byte value) {
char format[10];
sprintf(format, "0x%.2X ", value);
@silbo
silbo / Hanoi.java
Created January 10, 2016 21:17
non-recursive hanoi tower solver with 3 rods "n" disks in Java
public class Hanoi {
/*
* @param int - number of disks
*/
static void solve ( int n ) {
// create the rods
IntStack rod_A = new IntStack(n);
IntStack rod_B = new IntStack(n);
IntStack rod_C = new IntStack(n);