Skip to content

Instantly share code, notes, and snippets.

Avatar

Edgar Bonet edgar-bonet

  • Grenoble, France
View GitHub Profile
@edgar-bonet
edgar-bonet / subi_vs_andi.S
Created Sep 11, 2020
Compare the performance of `subi' and `andi'
View subi_vs_andi.S
; 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 / dual-scope.c
Created Jun 21, 2017
Dual channel Arduino/AVR oscilloscope
View dual-scope.c
/*
* 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 / stroboscope.ino
Created Aug 26, 2016
Pulse an LED at an adjustable frequency
View stroboscope.ino
/*
* 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
View sound-meter.ino
/*
* 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 Mar 1, 2016
Homodyne detection of a 1 kHz signal
View homodyne.ino
/*
* 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 / interpreter.ino
Last active Nov 19, 2020
Simple Arduino command line interpreter
View interpreter.ino
/*
* 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 / robotic-car-test.ino
Created Feb 23, 2016
Basic tests for a small robotic car
View robotic-car-test.ino
/*
* 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;
@edgar-bonet
edgar-bonet / ebclock.ino
Last active Nov 19, 2020
Alternate firmware for Daniel Andrade's binary clock
View ebclock.ino
/*
* 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