Pages: [1]   Go Down
Author Topic: Button Function  (Read 335 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Friends,

I have a project where I want to press a button multiple times, depending on the number of times I press the button, a certain function happens. I found this code online and am modifying it from here to do my own functions.
Code:
#include <Button.h>
/*
create a Button object at pin 12
connect button between pin 12 and GND
*/


Button button = Button(12,PULLDOWN);
 
void setup(){
  pinMode(8,OUTPUT); //debug to led 13
  pinMode(9,OUTPUT);
  pinMode(7,OUTPUT);
 
 
}
 byte pressCount = 0;
void loop(){

  if (button.uniquePress())
pressCount++;

switch(pressCount)
       
        {case 1:
         
          digitalWrite(7,HIGH);
        digitalWrite(9,LOW);
        digitalWrite(8,LOW);
 
  break;
 
  case 2:
 

        digitalWrite(8,HIGH);
        digitalWrite(7,LOW);
        digitalWrite(6,LOW);
   
   break;
   case 3:
     
 

        digitalWrite(9,HIGH);
        digitalWrite(8,LOW);
        digitalWrite(7,LOW);
       
pressCount = 0;
       break; 

  }

 
   }

I downloaded and installed the library from here:
http://arduino.cc/playground/Code/Button#CurrentVersion

When I compile the sketch I keep getting the following message:
Quote
no matching function for call 'Button::Button(int,int)'

Do you know what's up?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Which Arduino software version are you using? There are different Button libraries for Arduino 0022 and Arduino 1.0. Are you sure you have the right one? Note that PULLDOWN in the 0022 library was changed to BUTTON_PULLDOWN in the 1.0 library.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Full Member
***
Karma: 4
Posts: 187
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

change the include file

Wprogram.h to  "Arduino.h" in button.h

cheers
Logged

From Idea To Invention

Pages: [1]   Go Up
Jump to: