Sunday 28 October 2012

Arduino Rotary Encoder

http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html
Implementation with and without external interrupt. Using two encoders is also possible.

Saturday 27 October 2012

Stepper Motor 28BYJ-48 5V

http://arduino.cc/forum/index.php/topic,71964.0.html
Gear ratio: (22X26X31X32)/(9X9X10X11) = 63.68395.    ( 283712/4455) 

Friday 26 October 2012

Arduino Interrupt Software Debounce

Ref: http://www.dave-auld.net/index.php?option=com_content&view=article&id=107:arduino-interrupts&catid=53:arduino-input-output-basics&Itemid=107


int pbIn = 0;                  // Interrupt 0 is on DIGITAL PIN 2!
02.int ledOut = 4;                // The output LED pin
03.volatile int state = LOW;      // The input state toggle
04. 
05.void setup()
06.{               
07.// Set up the digital pin 2 to an Interrupt and Pin 4 to an Output
08.pinMode(ledOut, OUTPUT);
09. 
10.//Attach the interrupt to the input pin and monitor for ANY Change
11.attachInterrupt(pbIn, stateChange, CHANGE);
12.}
13. 
14.void loop()                    
15.{
16.//Simulate a long running process or complex task
17.for (int i = 0; i < 100; i++)
18.{
19.// do nothing but waste some time
20.delay(10);
21.}
22.}
23. 
24.void stateChange()
25.{
26.state = !state;
27.digitalWrite(ledOut, state); 
28.}