Go Down

Topic: button error (Read 978 times) previous topic - next topic

markthespark

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: [Select]
/*
||
|| @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&)

kjablonski

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

markthespark

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

kjablonski

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

markthespark

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

Arrch


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


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

kjablonski


markthespark

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

Arrch

#8
Oct 25, 2012, 11:53 pm Last Edit: Oct 25, 2012, 11:55 pm by Arrch Reason: 1

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.

Go Up