Go Down

Topic: Header files....!! (Read 1 time) previous topic - next topic

Sadan

i was trying to learn arduino programming from " A quick start guide: Maik Schmidt "..while making a dice game i stuck at a place. i have attached an image...i used bounce.h header file i don't know whether it was in my software or not. i am using 1.0.1....help me guys...i want to do some projects with arduino.....

Tom Carpenter

Unless you have specifically downloaded Bounce.h, the Arduino compiler can't include it. (It is not there by default)

I believe this is what you need:
http://www.arduino.cc/playground/code/bounce
~Tom~

PaulS

Quote
i used bounce.h header file i don't know whether it was in my software or not.

One of the biggest blunders of 1.0.1 is that missing include files are no longer fatal errors. Of course, the missing will will generate a bunch of other errors, which are fatal, but you won't know why.

You can use Tools + Import... to see if the library you want to use IS accessible/correctly installed.

Sadan


Unless you have specifically downloaded Bounce.h, the Arduino compiler can't include it. (It is not there by default)


i downloaded the file and copied it to my library...i modified my code a bit but it is still showing same error.....

dxw00d

Any chance you could stop posting screenshots, and just copy out ALL of the messages in the error box?

Where, exactly, have you put the bounce library? It looks like the IDE can't find it.

PaulS

Quote
i downloaded the file and copied it to my library

Then, you didn't do it right, or you didn't restart the IDE after doing it.

You can copy and paste the text in the IDE window, rather than post an image of your whole desktop.

Sadan

#6
Aug 22, 2012, 11:41 am Last Edit: Aug 22, 2012, 11:43 am by AWOL Reason: 1
Code: [Select]
#include <Bounce.h>

int LED_BIT0 = 12;
int LED_BIT1 = 11;
int LED_BIT2 = 10;
int START_BUTTON_PIN = 5;
int GUESS_BUTTON_PIN = 7;

void setup() {
 pinMode(LED_BIT0, OUTPUT);
 pinMode(LED_BIT1, OUTPUT);
 pinMode(LED_BIT2, OUTPUT);
 pinMode(START_BUTTON_PIN, INPUT);
 pinMode(GUESS_BUTTON_PIN, INPUT);
 Serial.begin(9600);
}

Bounce start_button = Bounce (START_BUTTON_PIN, 20);
Bounce guess_button = Bounce (GUESS_BUTTON_PIN, 20);
int guess = 0;

void loop() {
 handle_guess_button();
 handle_start_button();
}

void handle_guess_button() {
 if (guess_button.update()) {
   if (guess_button.read()== HIGH) {
     guess = (guess % 6) + 1;
     output_result(guess);
     Serial.print("Guess: ");
     Serial.println(guess);
   }
 }
}

void handle_start_button() {
 if (start_button.update()) {
   if (start_button.read() == HIGH) {
     int result = random(1, 7);
     output_result(result);
     Serial.print("Result: ");
     Serial.println(result);
     if (guess > 0) {
       if (result == guess) {
         Serial.println("You Win!");
         hooray();
       } else {
         Serial.println("You lose!");
       }
     }
     delay(2000);
     guess = 0;
   }
 }
}

void output_result(long result) {
 digitalWrite(LED_BIT0, result & B001);
 digitalWrite(LED_BIT1, result & B010);
 digitalWrite(LED_BIT2, result & B100);
}

void hooray() {
 for (int i = 0; i < 3; i++) {
   output_result(7);
   delay(500);
   output_result(0);
   delay(500);
 }
}

Moderator edit: code tags.

this is the code....i copied that in Arduino 1.0.1 > libraries

Sadan


Quote
i downloaded the file and copied it to my library

Then, you didn't do it right, or you didn't restart the IDE after doing it.



i restarted the IDE

dxw00d

Quote
this is the code....i copied that in Arduino 1.0.1 > libraries


Well, that's your problem then.

From the Bounce library page:
Quote
Put the Bounce folder in "your Arduino Sketchbook Location/libraries/". To identify this location open "menubar->File->Preferences".

In the Arduino IDE, select "menubar->Sketch->Import Library->Bounce" to import the library to your sketch. An "#include Bounce.h" line will appear at the top of your Sketch.

You can also find examples under "menubar->File->Sketchbook->libraries->Bounce"

Sadan

there is no libraries folder in my sketchbook folder...my default sketch book folder is in my documents...but i saved this code to some place else..

dxw00d

Then create a libraries folder in your sketchbook folder, and put the Bounce folder in it. That is the search location for downloaded libraries.

Sadan

its still not working   :(

dxw00d

Ok, so again, Where, exactly, have you put the bounce library? Post a screenshot that shows the complete path to Bounce.h in explorer. Then, copy ALL the errors you are getting, and post them too.

dxw00d

I've just downloaded the library and put it in the correct location. The output I get, compiling your sketch, is:
Code: [Select]
Binary sketch size: 4,454 bytes (of a 32,256 byte maximum)

Sadan

Picture 1 shows the sketchbook folder as you said file>preferences ....
in 2nd picture you can see i created a folder called libraries and placed bounce folder in it...
in picture three you see IDE is showing bounce folder in sketchbook

Go Up