Pakistan
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« on: August 21, 2012, 02:02:45 pm » |
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.....
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
God Member
Karma: 35
Posts: 983
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #1 on: August 21, 2012, 02:11:55 pm » |
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
Brattain Member
Karma: 311
Posts: 35483
Seattle, WA USA
|
 |
« Reply #2 on: August 21, 2012, 02:14:05 pm » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #3 on: August 22, 2012, 04:33:50 am » |
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.....
|
|
|
|
|
Logged
|
|
|
|
|
Gosport, UK
Offline
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #4 on: August 22, 2012, 04:37:14 am » |
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
Brattain Member
Karma: 311
Posts: 35483
Seattle, WA USA
|
 |
« Reply #5 on: August 22, 2012, 04:38:37 am » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #6 on: August 22, 2012, 04:41:37 am » |
#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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #7 on: August 22, 2012, 04:43:48 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #8 on: August 22, 2012, 04:44:30 am » |
this is the code....i copied that in Arduino 1.0.1 > libraries Well, that's your problem then. From the Bounce library page: 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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #9 on: August 22, 2012, 04:56:12 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #10 on: August 22, 2012, 05:02:34 am » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #11 on: August 22, 2012, 05:38:11 am » |
its still not working 
|
|
|
|
|
Logged
|
|
|
|
|
Gosport, UK
Offline
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #12 on: August 22, 2012, 05:42:48 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #13 on: August 22, 2012, 05:52:51 am » |
I've just downloaded the library and put it in the correct location. The output I get, compiling your sketch, is: Binary sketch size: 4,454 bytes (of a 32,256 byte maximum)
|
|
|
|
|
Logged
|
|
|
|
|
Pakistan
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #14 on: August 22, 2012, 05:56:50 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
|