first time user...using a HAPP button

Hello,

I am a first time user and i am not a programmer. I got this code from a tutorial on how to make a button act as a keystroke.

i.e. pressing the button will generate an input of "a" or whatever key i set it to.

here is the code:

/*
02	 * Button.pde
03	 */
04	 
05	void setup() {
06	  Serial.begin(9600);
07	  pinMode(10, INPUT_PULLUP);
08	  delay(4000);
09	}
10	 
11	void loop() {
12	  if (digitalRead(10) == HIGH) {
13	    delay(10);
14	  } else {
15	    Keyboard.print("a");
16	    delay(1000);
17	  }
18	  delay(10);
19	}

here is the error output i get:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.5 (Windows 7), Board: "Teensy 2.0"
sketch_oct24a:8: error: invalid digit "8" in octal constant
sketch_oct24a:9: error: invalid digit "9" in octal constant
sketch_oct24a:5: error: expected unqualified-id before numeric constant
sketch_oct24a:7: error: expected unqualified-id before numeric constant
sketch_oct24a:4: error: expected unqualified-id before numeric constant
sketch_oct24a:10: error: expected unqualified-id before numeric constant

I am assuming the errors are at line 8,9,5,7,4,10...
any help would be GREATLY appreciated!

(deleted)

Usually you have to put something like

#include "arduino.h"

at the top of your program. Depends which version of the device and IDE you have.

I am not sure what Keyboard is, and I am not sure if the compiler knows, either.

You should consider "debouncing" the switch, but that is not causing your compilation error.

8 and 9 are indeed not valid octal digits, but they don't visibly appear in your program anywhere. You need to be aware
that the line numbers of the errors are sometimes spurious, and sometimes occur in included header files, but you don't
have any included header files here anyway.

Check you don't have any garbage characters outside the screen view at the end of long lines of blanks in the code.

Apart from those issues, your code looks valid to me.

Are those line numbers actually in your source code file :stuck_out_tongue_closed_eyes:

Yes. get rid of those.

spycatcher2k:
Yip - remove the line numbers

:blush: :blush: :blush: :blush: :blush: :blush:

wow!! that was embarrassing!!!

thank you guys hahahaha i will now go hang my head in shame for the rest of the day!!

Yes, those numbers make a bit of a mess.

Also, are you using Arduino Leonardo? Otherwise, Keyboard will not work. Use Serial.println("a") instead, for test.

michinyon:
Check you don't have any garbage characters outside the screen view at the end of long lines of blanks in the code.

Or at the beginning of long lines of code.

enanthate:
Yes, those numbers make a bit of a mess.

Also, are you using Arduino Leonardo? Otherwise, Keyboard will not work. Use Serial.println("a") instead, for test.

it wont work with a teensy?

If this is for a Teensy you would be better off posting your question in a Teensy forum at PJRC (Teensy) Forum

Pete