Skip to content

Instantly share code, notes, and snippets.

const int trigPin = 3;
const int echoPin = 2;
void setup()
{
// initialize serial communication:
Serial.begin(115200);
}
void loop()
@FrankBuss
FrankBuss / bateye-improved.c
Created May 26, 2017 21:14
improved version for the bateye hardware
// pin definitions
// note: the echoPin has to be a pin which is allowed for interrupts, see here: https://www.arduino.cc/en/Reference/attachInterrupt
const int trigPin = 3;
const int echoPin = 2;
const int ledPin = 13;
const int speakerPin = 9;
// interrupt speed. the datasheet of the HC-SR04 suggests 60 ms, so chose 16 Hz
const float irqSpeed = 16.0;
@FrankBuss
FrankBuss / quantize-test.c
Created July 23, 2017 15:49
quantization test for synthesizer CV
/**
* Quantize test:
* Arduino Nano pins for the MCP4822 DAC: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).
* potentiometer input: A0
*/
#include "SPI.h"
// pin numbers
const int ledPin = 13;
const int csPin = 10;
@FrankBuss
FrankBuss / DAC8718-test.c
Created August 4, 2017 18:42
3 Hz sawtooth example with a DAC8718
/**
* 3 Hz sawtooth example with a DAC8718
* Arduino Nano pins:
* CS: 10
* MOSI: 11
* MISO: 12
* SCK: 13
*/
#include "SPI.h"
@FrankBuss
FrankBuss / level-shifter.asc
Created October 1, 2017 21:29
bi-directional level shifter

Version 4 SHEET 1 880 680 WIRE 80 -32 -144 -32 WIRE 176 -32 80 -32 WIRE 544 -32 336 -32 WIRE 80 32 80 -32 WIRE 336 32 336 -32 WIRE -144 128 -144 -32 WIRE 544 144 544 -32 WIRE 176 160 176 -32

@FrankBuss
FrankBuss / fluke-8842a-logging.py
Created October 18, 2017 13:22
writes a voltage measurement with second timestamp every second
# Python script for voltage logging
import os.path
import sys
import Gpib
import time
# GPIB Address = 24
inst = Gpib.Gpib(0,24, timeout=60)
inst.clear()
inst.write("G8")
segmentImage = Image.load("segment.png")
pi = 4*math.atan(1)
green = Color.new(0,255,0)
black = Color.new(0,0,0)
segmentSize = segmentImage:width()
segmentSpace = segmentSize - 2
width = 480 + 2 * segmentSize
height = 272 + 2 * segmentSize
function init()
import math
# highest note frequency
c = 4186.01
# distance factor between two notes
f = pow(2, 1.0/12.0)
# show frequncies
ds = [ 239, 253, 268, 284, 301, 319, 338, 358, 379, 402, 426, 451 ]
@FrankBuss
FrankBuss / merge-c2d.py
Last active September 29, 2018 11:26
merge two c2d (Carbid Create) files
#!/usr/bin/python3
import json
import argparse
# parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument('master')
parser.add_argument('file_to_merge')
parser.add_argument('output_file')
args = parser.parse_args()
; ATTiny25 implementation of a NAND
; PB1 and PB2 is input, with pullups, and PB0 is output
; fuse settings: disable CKDIV8 for 8 MHz clock
start:
; set PB0 as output, all other pins as input
ldi r20, 1
out DDRB, r20