Skip to content

Instantly share code, notes, and snippets.

View edgar-bonet's full-sized avatar

Edgar Bonet edgar-bonet

  • Grenoble, France
  • 09:32 (UTC +01:00)
View GitHub Profile
@edgar-bonet
edgar-bonet / interpreter.ino
Last active February 4, 2024 12:26
Simple Arduino command line interpreter
/*
* interpreter.ino: Simple Arduino command line interpreter.
*
* This is intended solely as a template for building richer,
* application-specific interpreters. Add your specific commands to the
* exec() function, and whatever you need to setup() and loop().
*
* Usage:
* Talk to it through the serial port at 9600/8N1. Commands should be
* terminated by CR (\r), answers are terminated by CRLF (\r\n). This
@edgar-bonet
edgar-bonet / sound-meter.ino
Created March 16, 2016 14:29
Arduino sound meter
/*
* sound-meter.ino: Arduino sound meter.
*
* This program continuously samples a sound signal on analog input 0
* and outputs the computed sound intensity through the serial port.
*
* The analog-to-digital converter is set to "free running mode" and
* takes one sample every 104 us. After subtracting a DC offset
* (constant dc_offset below), the samples are squared and low-pass
* filtered with a time constant of 256 sample periods (26.6 ms). They
@edgar-bonet
edgar-bonet / homodyne.ino
Created March 1, 2016 12:00
Homodyne detection of a 1 kHz signal
/*
* homodyne.ino: Homodyne detection of a 1 kHz signal.
*
* This program continuously samples analog input 0 and uses an homodyne
* detection scheme to identify a signal at 1 kHz (+/- 24 Hz @ -3dB).
*
* The analog-to-digital converter is set to "free running mode" and
* takes one sample every 104 us. The samples are multiplied by two
* generated signals at 1 kHz (the "local oscillator"), in quadrature to
* one another. The products are then low-pass filtered with a time
@edgar-bonet
edgar-bonet / dual-scope.c
Created June 21, 2017 20:03
Dual channel Arduino/AVR oscilloscope
/*
* dual-scope.c: Dual channel Arduino/AVR oscilloscope.
*
* This program alternatively samples analog inputs 0 and 1, with an
* overall sampling rate of about 9615 samp/s (one sample every 104 us),
* i.e. 4808 samp/s per channel. The samples are output as 8-bit binary
* through the serial port at 115200/8N1. A fixed 16-byte ASCII prologue
* is sent at program startup, before the actual binary data, for
* synchronization purposes. The first byte sent after the prologue is a
* sample from channel 0.
@edgar-bonet
edgar-bonet / ebclock.ino
Last active November 19, 2020 23:02
Alternate firmware for Daniel Andrade's binary clock
/*
* ebclock.ino: Edgar's binary clock.
*
* This is an alternate firmware for Daniel Andrade's binary clock.
* For details and schematic, see Daniel's post at
* http://www.danielandrade.net/2008/07/15/binary-clock-with-arduino/
*
* A few things are changed with respect to the original firmware:
* - you can fine-tune the clock speed if it runs too fast or too slow
* - you do not need the 2.2 KOhm pull-up resistors
@edgar-bonet
edgar-bonet / subi_vs_andi.S
Created September 11, 2020 20:42
Compare the performance of `subi' and `andi'
; subi_vs_andi.S: Compare the performance of `subi' and `andi'
;
; Does a bitwise "and" perform better than a subtraction on an
; Arduino Uno?
;
; There are two common ways of converting an ASCII digit to its numeric
; value:
;
; - subtraction: character - '0'
; - bitwise and: character & 0x0f
@edgar-bonet
edgar-bonet / stroboscope.ino
Created August 26, 2016 15:00
Pulse an LED at an adjustable frequency
/*
* stroboscope.ino: Pulse an LED at an adjustable frequency.
*
* This program strobes an LED at a frequency which is controlled by a
* potentiometer. The frequency is continuously displayed on the serial
* port.
*
* The potentiometer sets the frequency, on a logarithmic scale, from
* 15.26 to 1012 Hz (assuming a 16 MHz clock). The output is generated
* by Timer 1 in phase correct PWM mode with a /8 prescaler. This
@edgar-bonet
edgar-bonet / robotic-car-test.ino
Created February 23, 2016 12:05
Basic tests for a small robotic car
/*
* robotic-car-test.ino: Basic tests for a small robotic car.
*
* Usage: keep the car in your hand and look at the serial monitor.
*/
#include <Servo.h>
// Pinout.
const int MOTOR_LEFT_ENABLE = 6;