<> = Programming the Arduino = This is a collection of links and tips on how to program the Arduino. Main source is [[http://playground.arduino.cc//Main/GeneralCodeLibrary|the Arduino.cc Code Library]]. == Push buttons == * [[http://playground.arduino.cc/Code/AvoidDelay|How and Why to avoid using delay()]] * == Sound Generation == * [[http://playground.arduino.cc//Main/Freqout|Generating musical signals using freqout()]] == Fast Division == === fast division by 10 === * [[http://forum.arduino.cc/index.php?topic=167414.0|Fast division by 10]] [[attachment:Fast division by 10]] {{{ void divmod10(uint32_t in, uint32_t &div, uint32_t &mod) { uint32_t x=(in>>1); // div = in/10 <==> div = ((in/2)/5) uint32_t q=x; q= (q>>8) + x; q= (q>>8) + x; q= (q>>8) + x; q= (q>>8) + x + 1; x= q; q= (q>>1) + x; q= (q>>3) + x; q= (q>>1) + x; div = (q >> 3); mod = in - (((div << 2) + div) << 1); } }}} This was the earlier version: [[attachment:Fast division by 10 early version]] {{{ void divmod10(uint32_t in, uint32_t &div, uint32_t &mod) { // q = in * 0.8; uint32_t q = (in >> 1) + (in >> 2); q = q + (q >> 4); q = q + (q >> 8); q = q + (q >> 16); // not needed for 16 bit version // q = q / 8; ==> q = in *0.1; q = q >> 3; // determine error uint32_t r = in - ((q << 3) + (q << 1)); // r = in - q*10; div = q + (r > 9); if (r > 9) mod = r - 10; else mod = r; } }}} == Home Automation == * [[http://www.souliss.net/|Internet of Things at Souliss]] == Doing Two things at Once == * [[http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay|Blink without delay()]] * [[http://www.uchobby.com/index.php/2012/01/21/replacing-delay-in-arduino-sketches-istime-to-the-rescue/#more-593|Replacing delay() with IsTime()]] == Logic Probe == * [[http://www.swansontec.com/sprobe.html| Op-Amp-based logic probe]] No Arduino needed for this.