So I an using an Arduino Leonardo controller to control a RaspberryPie w/ RetroPie. Basically to convert Joystick and buttons to control a videogame.
When I upload the sketch, I get the error: "expected unqualified-id before numeric constant".
I can see the Arduino controller on my laptop and can communicate with it, but there is an error uploading the sketch.
Any suggestions??
Thanks!
Here is the code I am trying to upload:
01.//element14 PIK3A Gaming Table Controls, using an Arduino Leonardo//
02.
03.void setup() {
04. Keyboard.begin();
05.
06.
07. //Joystick and buttons pin allocations
08. pinMode(0, INPUT_PULLUP); //Joystick Up
09. pinMode(1, INPUT_PULLUP); //Joystick Down
10. pinMode(2, INPUT_PULLUP); //Joystick Left
11. pinMode(3, INPUT_PULLUP); //Joystick Right
12. pinMode(4, INPUT_PULLUP); //Button 1
13. pinMode(5, INPUT_PULLUP); //Button 2
14. pinMode(6, INPUT_PULLUP); //Button 3
15. pinMode(7, INPUT_PULLUP); //Button 4
16. pinMode(8, INPUT_PULLUP); //Coin
17. pinMode(9, INPUT_PULLUP); //Start
18.}
19.
20.
21.void loop() {
22.
23.
24. // Button labels:
25. int joystickUp = digitalRead(0);
26. int joystickDown = digitalRead(1);
27. int joystickLeft = digitalRead(2);
28. int joystickRight = digitalRead(3);
29. int button1 = digitalRead(4);
30. int button2 = digitalRead(5);
31. int button3 = digitalRead(6);
32. int button4 = digitalRead(7);
33. int coin = digitalRead(8);
34. int start = digitalRead(9);
35.
36.
37. // Joystick Up - Arrow Up Key
38. if (joystickUp == LOW) {
39. Keyboard.press(218);
40. }
41. else {
42. Keyboard.release(218);
43. }
44.
45.
46. // Joystick Down - Arrow Down Key
47. if (joystickDown == LOW) {
48. Keyboard.press(217);
49. }
50. else {
51. Keyboard.release(217);
52. }
53.
54.
55. // Joystick Left - Arrow Left Key
56. if (joystickLeft == LOW) {
57. Keyboard.press(216);
58. }
59. else {
60. Keyboard.release(216);
61. }
62.
63.
64. // Joystick Right - Arrow Right Key
65. if (joystickRight == LOW) {
66. Keyboard.press(215);
67. }
68. else {
69. Keyboard.release(215);
70. }
71.
72.
73. // Button 1 - Left CTRL
74. if (button1 == LOW) {
75. Keyboard.press(128);
76. }
77. else {
78. Keyboard.release(128);
79. }
80.
81.
82. // Button 2 - Left ALT
83. if (button2 == LOW) {
84. Keyboard.press(130);
85. }
86. else {
87. Keyboard.release(130);
88. }
89.
90.
91. // Button 3 - Left CTRL
92. if (button3 == LOW) {
93. Keyboard.press(32);
94. }
95. else {
96. Keyboard.release(32);
97. }
98.
99.
100. // Button 4 - Left CTRL
101. if (button4 == LOW) {
102. Keyboard.press(129);
103. }
104. else {
105. Keyboard.release(129);
106. }
107.
108.
109. // Coin - 5
110. if (coin == LOW) {
111. Keyboard.press(53);
112. }
113. else {
114. Keyboard.release(53);
115. }
116.
117.
118. // Start - 1
119. if (start == LOW) {
120. Keyboard.press(49); delay(100);
121. }
122. else {
123. Keyboard.release(49);
124. }
125.
126.}