Pages: [1] 2   Go Down
Author Topic: Header files....!!  (Read 1074 times)
0 Members and 1 Guest are viewing this topic.
Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.....


* Untitled.png (1122.27 KB, 1366x768 - viewed 22 times.)
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

~Tom~

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46253
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.....


* Untitled.png (1208.33 KB, 1366x768 - viewed 9 times.)
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46253
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#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
« Last Edit: August 22, 2012, 04:43:08 am by AWOL » Logged

Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"
Logged

Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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..
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

its still not working   smiley-sad
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* Bounce.jpg (91.91 KB, 800x600 - viewed 11 times.)
Logged

Pakistan
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* 1.png (287.92 KB, 1366x768 - viewed 7 times.)

* 2.png (191.3 KB, 1366x768 - viewed 8 times.)

* 3.png (186.77 KB, 1366x768 - viewed 8 times.)
Logged

Pages: [1] 2   Go Up
Jump to: