donderdag 6 mei 2010

Update for AdvBut

Today I released a new version of AdvBut. The adanced button library for the Arduino platform.

New features:
  1. Debouncing detection
  2. Button repeat improved
  3. New parameter in constructor, allowing the use of analog buttons

Get it while it's fresh from http://www.arduino.cc/playground/Code/AdvButton

woensdag 14 april 2010

Electronic component: MAX756

I Wondered if it is possible to run an Arduino on 1 battery. Obviously, there are problems. The Atmega won't run on anything lower than 3.3v. As one battery gives 1.5v, we are a bit short on volts.

Luckily, there is the MAX756. This IC has the possibility to increase the voltage. Of course this has a disadvantage, the amount of Ampere will decrease. So, you are (more) limited on how much you can power.

The following circuit will accept anything between 0.7 an 5v, so you can also use 2 batteries if you want. The output is 5v, more than enough to power you arduino.

You will need the following components:
1 x MAX756
1 x 22 uH axial RF choke
1 x 1N5817 Schottky diode
2 x 1 uF Electrolytic Capacitator
2 x 100 uF Electrolytic Capacitator

 The MAX756 is quite expensive in low quantities, I bought one for 5€. If you find them cheaper, please let me know.

zondag 24 januari 2010

AdvButton, a button library for the Arduino platform

I've decided to create a library for using buttons on the Arduino platform. See also http://www.arduino.cc/playground/Code/AdvButton.

Features

  1. Event based implementation
  2. Recording the time a button is pressed
  3. Adjustable repeat delay, start delay for the keypressed event
  4. requires only a single call in the main loop

Download, install and import

Download here: Attach:AdvButton.zip
 
Extract the folder AdvButton under /hardware/libraries/. (Re)start the Arduino application and select from the menu bar: "Sketch->Import Library->AdvButton". The following lines should be added: 


#include < AdvButton.h >
#include < ButtonManager.h >
 
See the file buttondemo.pde, included in the zip, for an example.

Usage

After importing the header files, declare the buttons:


#define PINBUTTON1 2
#define PINBUTTON2 3

#define PINLIGHT1 8
#define PINLIGHT2 9

AdvButton but1 = AdvButton(PINBUTTON1,OnKeyPressBut1,100,1000);
AdvButton but2 = AdvButton(PINBUTTON2,NULL,OnKeyDownBut2,OnKeyUpBut2);
 
Button 1 will generate a keypress event upon pressing the button at pin 2. After a short delay (1000 milliseconds), every 100 milliseconds the keypress event is raise again. Until the button is released.
Button 2 will generate a keydown event upon pressing the button at pin 3. After releasing the button a keyup event is raised.
Next we need to define the event functions. The triggering button is passed as parameter.


void OnKeyPressBut1(AdvButton* but)
{
  digitalWrite(PINLIGHT1,HIGH);
  delay(5);
  digitalWrite(PINLIGHT1,LOW);
}


void OnKeyDownBut2(AdvButton* but)
{
  digitalWrite(PINLIGHT2,HIGH);

}

void OnKeyUpBut2(AdvButton* but)
{
  digitalWrite(PINLIGHT2,LOW);
}
 
Last is the adding a call to the buttonmanager to update the button states:



void loop()
{
  ButtonManager::instance()->checkButtons();
}