Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have no idea
where is my header file!! help
C++
typedef unsigned char byte;
// included libraries
#include <LiquidCrystal.h>
#include <Button.h>

// pin definitions
#define START_BUTTON_PIN 6
//-7-

// variable initialize 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Button start_button = Button(START_BUTTON_PIN, BUTTON_PULLUP);
//-8-

unsigned long timerInterval = 1000; // duration variable in milliseconds
//-1-
unsigned long timerLastStart = 0;  // Last Start Time variable in milliseconds
//-2-
int secondCount1 = 0;
//-3-

//-5-

void setup () {
  Serial.begin (9600);
  Serial.println("Non Blocking Timer");
  Serial.println("Lets Begin");

  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Timer: ");
  lcd.print(secondCount1);
  lcd.print ("s");

  //-6-

}

void loop () {

  if (start_button.uniquePress ()) {
  } 

  //-9-

  if(millis() - timerLastStart > timerInterval) {
    timerLastStart = millis();
    // event code
    secondCount1++;
    lcd.setCursor(0, 0);  
    lcd.print("Timer: ");
    lcd.print(secondCount1);
    lcd.print ("s");  
  }

  //-4-

}
Posted
Comments
CHill60 10-Jun-15 8:35am    
if you use #include "Button.h" does that work?

1 solution

Your code snippet is from http://workshopweekend.net/arduino/projects/stopwatch[^].

There are two links on that page:
One to download the button library and one to a PDF with instructions.

So you must download the library and install it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900