bounce errors

hey
im trying to use some cos i found to make a timelapse dolly but it comes back with some errors like bounce does not name a type

this is the line i think may be causing the problem as its highlighted in yellow when i try to verify or run the code

Bounce bouncer1 = Bounce(button1, 15); //deblounce (button, milliseconds)

and these are the errors

'Bounce' does not name a type
timelapselcd:25: error: 'Bounce' does not name a type
timelapselcd:26: error: 'Bounce' does not name a type
timelapselcd:27: error: 'Bounce' does not name a type
timelapselcd:28: error: 'Bounce' does not name a type
timelapselcd.ino: In function 'void loop()':
timelapselcd:59: error: 'bouncer1' was not declared in this scope
timelapselcd:60: error: 'bouncer2' was not declared in this scope
timelapselcd:61: error: 'bouncer3' was not declared in this scope
timelapselcd:62: error: 'bouncer4' was not declared in this scope

Any help would be appreciated

thanks :slight_smile:

lupowarrior:
hey
im trying to use some cos i found to make a timelapse dolly but it comes back with some errors like bounce does not name a type

Kindly post the code.

    /*
    LCD screen for motorized camera dolly
    Code written by: Philip Sorri
    */
     
    #include <LiquidCrystal.h> //LCD library
    #include <Bounce.h> //debounce library
    int button3 = 6; //button pins
    int button2 = 7;
    int button1 = 8;
    int startStop = 9;
    int runTime1;
    int show = 1;     //what menu to show
    int dollySpeedNum = 0; //number of the speed
    int delayTime = 100; //delay after pressedbutton (see the functions)
    int delayDolly = 0; //delay before running
    int runTime = 0;    //time to run after delay
    int motorPin = 10;
    int val4;
    int shutter = 1;
    int shutterCount = 0;
    int shutterVal = 0;
    Bounce bouncer1 = Bounce(button1, 15); //deblounce (button, milliseconds)
    Bounce bouncer2 = Bounce(button2, 15);
    Bounce bouncer3 = Bounce(button3, 15);
    Bounce bouncer4 = Bounce(startStop, 15);
     
    LiquidCrystal lcd(12,11,5,4,3,2); //pins of the LCD to arduino
     
    void setup() {
      pinMode(button1, INPUT); //button as inputs
      pinMode(button2, INPUT);
      pinMode(button3, INPUT);
      pinMode(startStop, INPUT);
      pinMode(motorPin, OUTPUT);
      pinMode(shutter, OUTPUT);
      lcd.begin(16,2);
      lcd.setCursor(0,0);
      lcd.print("DOLLYDUINO V 1.1");
      lcd.setCursor(0,1);
      lcd.print("By ThePhilleBoy");
      delay(3000);
    }
     
    void loop() {
      if(shutterVal > 1) {
        shutterVal = 0;
      }
     
      runTime1 = runTime;
      if(runTime == 0) {
        runTime1 = 10;
      }
      else {
        runTime1 = runTime;
      }
      bouncer1.update();  //update the buttons
      bouncer2.update();
      bouncer3.update();
      bouncer4.update();
      int val1 = bouncer1.read(); //reads the value
      int val2 = bouncer2.read(); //and sets the new variables to it
      int val3 = bouncer3.read(); //So if button is pressed value = HIGH
      val4 = bouncer4.read();
     
      if (show > 4) {              //Number of menus
        show = 1;
      }
      if(val3 == HIGH) {    //scroll through the different menus
        show = show + 1;    //the show number indicates which menu we're in
        delay(delayTime * 5);
      }
      if(show == 1) {      //if show is 1 the dollySpeed function is chosen/shown
        dollySpeed(val1, val2);  //To change values in this menu with same buttons
      }                          //in all the menus
      else if(show == 2) {  //if show is 2 delay function is chosen/shown on LCD
        dollyDelay(val1, val2);
      }
      else if(show == 3) {
        runningTime(val1, val2);
      }
      else if(show == 4) { //shows all the setting that are chosen
        settings();
        if(val1 == HIGH || val2 == HIGH) {
          shutterVal = shutterVal + 1;
          delay(delayTime*3);
        }
      }
     
      if(val4 == HIGH && shutterVal == 0){
      motorOn();
    }
      if(val4 == LOW){
      analogWrite(motorPin, LOW);
    }
      if(val4 == HIGH && shutterVal == 1) {
      motorOn();
      lcd.setCursor(0,0);
      lcd.print("P:");
      lcd.setCursor(4,0);
      lcd.print(shutterCount);
    }
    }
     
    void dollySpeed(int num1, int num2) {
      lcd.setCursor(0,0);    //sets the startpoint of the text to (0,0)
      lcd.print("Dolly speed:    "); //Writes "Dolly speed:" to the LCD
      if(num1 == HIGH) { //if num1 which is val1/button1 is pressed the speed
        dollySpeedNum = dollySpeedNum + 1;  //increases with 1
        delay(delayTime);      //delay before next press, otherwise it would
      }                         //scroll fast as hell
      if(num2 == HIGH) {        //if button2 is pressed decrease with 1
        dollySpeedNum = dollySpeedNum - 1;
        delay(delayTime);
      }
      lcd.setCursor(0,1);  //sets the starting point of the print
      lcd.print(dollySpeedNum); //prints to the start point (0,1)
      if(dollySpeedNum < 10) {
        lcd.setCursor(1, 1);
        lcd.print("%             "); //makes a percent sign after the number
      }                      //the space after it is to hide numbers that might
      if(dollySpeedNum >= 10 && dollySpeedNum < 100) { //be shown from the last
        lcd.setCursor(2, 1);            //menu that we scrolled from.
        lcd.print("%      "); //if the speed if over 10 and less than 100 it moves
      }                        //the percentsign one step to the right.
      if(dollySpeedNum == 100) { //same here
        lcd.setCursor(3, 1);
        lcd.print("%      ");
      }
      if(dollySpeedNum > 100) { //I wanted the speed to be in percent so I
        dollySpeedNum = 0;      //have to limit the value of dollySpeedNum.
      }                         //if the value is higher than 100 it makes it to 0
      if(dollySpeedNum < 0) {   //and if it's lower than 0 it goes to 100.
        dollySpeedNum = 100;
      }
    }
     
    void dollyDelay(int but1, int but2) {
      int decimal;
      decimal = delayDolly%10;
      lcd.setCursor(0,0);
      lcd.print("Delay:          ");
      if(but1 == HIGH) {
        delayDolly = delayDolly + 1;
        delay(delayTime);
      }
      if(but2 == HIGH) {
        delayDolly = delayDolly - 1;
        delay(delayTime);
      }
      lcd.setCursor(0,1);
      lcd.print(delayDolly/10);
      if(delayDolly < 10) {
        lcd.setCursor(1, 1);
        lcd.print(".");
        lcd.setCursor(2,1);
        lcd.print(decimal);
        lcd.setCursor(3,1);
        lcd.print(" s    ");
      }
      if(delayDolly >= 10 && delayDolly < 100) {
        lcd.setCursor(1, 1);
        lcd.print(".");
        lcd.setCursor(2,1);
        lcd.print(decimal);
        lcd.setCursor(3,1);
        lcd.print(" s    ");
      }
      if(delayDolly > 99) {
        lcd.setCursor(2, 1);
        lcd.print(".");
        lcd.setCursor(3,1);
        lcd.print(decimal);
        lcd.setCursor(4,1);
        lcd.print(" s    ");
      }
      if(delayDolly > 999) {
        delayDolly = 0;
      }
      if(delayDolly < 0) {
        delayDolly = 999;
      }
    }
[code] void runningTime(int num1, int num2) {
      int decimal1;
      decimal1 = runTime%10;
      lcd.setCursor(0,0);
      lcd.print("Run time:       ");
      if(num1 == HIGH) {
        runTime = runTime + 1;
        delay(delayTime);
      }
      if(num2 == HIGH) {
        runTime = runTime - 1;
        delay(delayTime);
      }
      lcd.setCursor(0,1);
      lcd.print(runTime/10);
      if(runTime < 10) {
        lcd.setCursor(1, 1);
        lcd.print(".");
        lcd.setCursor(2,1);
        lcd.print(decimal1);
        lcd.setCursor(3,1);
        lcd.print(" s    ");
      }
      if(runTime >= 10 && runTime < 100) {
        lcd.setCursor(1, 1);
        lcd.print(".");
        lcd.setCursor(2,1);
        lcd.print(decimal1);
        lcd.setCursor(3,1);
        lcd.print(" s    ");
      }
      if(runTime > 99) {
        lcd.setCursor(2, 1);
        lcd.print(".");
        lcd.setCursor(3,1);
        lcd.print(decimal1);
        lcd.setCursor(4,1);
        lcd.print(" s    ");
      }
      if(runTime > 999) {
        runTime = 0;
      }
      if(runTime < 0) {
        runTime = 999;
      }
    }
     
    void settings() {
      int decimal1;
      int decimal2;
      decimal1 = runTime%10;
      decimal2 = delayTime%10;
      lcd.setCursor(0,0);
      lcd.print("S: ");
      lcd.setCursor(3,0);
      lcd.print(dollySpeedNum);
      if(dollySpeedNum < 10) {
        lcd.setCursor(4,0);
        lcd.print("%   ");
      }
      if(dollySpeedNum >= 10 && dollySpeedNum < 100) {
        lcd.setCursor(5,0);
        lcd.print("%  ");
      }
      if(dollySpeedNum == 100) {
        lcd.setCursor(6,0);
        lcd.print("% ");
      }
     
      lcd.setCursor(8,0);
      lcd.print("R: ");
      lcd.setCursor(11,0);
      lcd.print(runTime/10);
      if(runTime < 10) {
        lcd.setCursor(12, 0);
        lcd.print(".");
        lcd.setCursor(13,0);
        lcd.print(decimal1);
        lcd.setCursor(14,0);
        lcd.print("s");
      }
      if(runTime >= 10 && runTime < 100) {
        lcd.setCursor(12,0);
        lcd.print(".");
        lcd.setCursor(13,0);
        lcd.print(decimal1);
        lcd.setCursor(14,0);
        lcd.print("s");
      }
      if(runTime > 99) {
        lcd.setCursor(13,0);
        lcd.print(".");
        lcd.setCursor(14,0);
        lcd.print(decimal1);
        lcd.setCursor(15,0);
        lcd.print("s");
    }
     
    lcd.setCursor(0,1);
      lcd.print("D: ");
      lcd.setCursor(3,1);
      lcd.print(delayDolly/10);
      if(delayDolly < 10) {
        lcd.setCursor(4, 1);
        lcd.print(".");
        lcd.setCursor(5,1);
        lcd.print(decimal1);
        lcd.setCursor(6,1);
        lcd.print("s");
      }
      if(delayDolly >= 10 && delayDolly < 100) {
        lcd.setCursor(4,1);
        lcd.print(".");
        lcd.setCursor(5,1);
        lcd.print(decimal2);
        lcd.setCursor(6,1);
        lcd.print("s");
      }
      if(delayDolly > 99) {
        lcd.setCursor(5, 1);
        lcd.print(".");
        lcd.setCursor(6,1);
        lcd.print(decimal1);
        lcd.setCursor(7,1);
        lcd.print("s");
    }
    if(val4 == LOW) {
    if(shutterVal == 0) {
    lcd.setCursor(10,1);
    lcd.print("I=OFF");
    }
    if(shutterVal == 1) {
      lcd.setCursor(10,1);
      lcd.print("I=ON ");
    }
    }
    }
     
    void motorOn () {
      int speedValue = map(dollySpeedNum, 0, 100, 0, 255);
      analogWrite(motorPin, speedValue);
        delay(runTime1*100);
        if(delayDolly > 0) {
        analogWrite(motorPin, LOW);
        picture();
        shutterCount = shutterCount + 1;
        delay(delayDolly*100);
      }
    }
     
    void picture() {
      pinMode(shutter, HIGH);
      delay(50);
      pinMode(shutter, LOW);
    }

[/code]

sorry had to split the code in to to make it go on because its quite long

thanks :smiley:

Read this and then edit your posts to use code tags: How to post code properly

Pete

sorry im a newbie Newbie thanks for the tip :slight_smile:

I tried your code and other than having to fix up my copy of the Bounce library so that it uses Arduino.h instead of WProgram.h, it compiled without problem. So my guess is that you haven't got the Bounce library installed.
In the IDE menu File|Preferences, select Show verbose output during compilation and then recompile the code. I think you will now get a warning message saying that it couldn't find Bounce.h

Once you have the Bounce library installed, it should compile properly.
http://playground.arduino.cc/code/bounce

Pete