Pages: [1]   Go Down
Author Topic: button error  (Read 876 times)
0 Members and 1 Guest are viewing this topic.
uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all
im trying to add a button function to a sketch but befor i add the code i tried the example but get errors why ??
Code:
/*
||
|| @file Button.pde
|| @version 1.1
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Display the intuitive way of using a button when using this Hardware Abstraction class
|| #
||
|| @license
|| | Copyright (c) 2009 Alexander Brevig. All rights reserved.
|| | This code is subject to AlphaLicence.txt
|| | alphabeta.alexanderbrevig.com/AlphaLicense.txt
|| #
||
*/

#include <Button.h>

//create a Button object at pin 12
/*
|| Wiring:
|| GND -----/ ------ pin 12
*/
Button button12 = Button(12,PULLUP);


void setup(){
  Serial.begin(9600);
  pinMode(13,OUTPUT); //debug to led 13 ^show led if button pushed
}

void loop(){
  if(button12.isPressed()){
      digitalWrite(13,HIGH);
        Serial.print("12"); //attempt to print to serial as well
        delay(250); //set delay
  }else{
      digitalWrite(13,LOW);
  }

}

In file included from sketch_oct25a.cpp:20:
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:23:22: error: WProgram.h: No such file or directory
In file included from sketch_oct25a.cpp:20:
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:34: error: expected `)' before 'buttonPin'
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:42: error: 'uint8_t' does not name a type
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:43: error: 'uint8_t' does not name a type
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:44: error: 'uint8_t' does not name a type
sketch_oct25a:26: error: no matching function for call to 'Button::Button(int, int)'
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:32: note: candidates are: Button::Button()
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0-windows\arduino-1.0\libraries\Button/Button.h:32: note:                 Button::Button(const Button&)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using the new version of the IDE you will need to remove the WProgram.h reference from the Button.h library.  Change that line to #include "Arduino.h".  Nick Gammon wrote a sticky that refernces this error. http://arduino.cc/forum/index.php/topic,97455.0.html
Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

is there a button update for the Version 1.0 of the IDE
i am still having problems
i have changed the  #include "WProgram.h"


If you get errors try locating such places and changing that line to:

Code:

#include "Arduino.h"

but still no joy so i must be doing some thing wrong
is there an online tutorial ?

all i want is a button to begin sequence on the sketch
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've never used the Button library, and its not referenced on the Arduino libraries page so I have no idea of its inner workings.  Where did you get it?  You might want to look into the Bounce library http://arduino.cc/playground/Code/Bounce
Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

got it here
http://arduino.cc/playground/Code/Button
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Did you try the link on that page for the version 1.0 library?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

there is a version for 1.0 available here http://github.com/tigoe/Button/archives/master
Logged

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes tried and got link
but still no joy will try again later
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes tried and got link
but still no joy will try again later

Considering the link provided above has a file Button.h which does not have a "WProgram.h" on line 23, I doubt you're getting the exact same error message. If you are, then you aren't installing the library properly. You shouldn't be putting it in the Arduino library folder anyway, it should be put in the libraries folder located in the same folder as your sketchbook.

Try deleting the old library, downloading the new one from the link above, and extracting it into a "libraries" subdirectory within your sketchbook folder and I bet you it will work.
« Last Edit: October 25, 2012, 04:55:46 pm by Arrch » Logged

Pages: [1]   Go Up
Jump to: