I am very new to arduino code writing and have built two button boxes. The first one worked without a problem, probably because i built it and used the code they used for that specific box. This time i built a different design and not sure about writing code for it.
I am using a Mini Nano v3.0 ATmega 328P
Attached is the box layout but I used a Pro Micro board for the diagram. It was what I was using for the first box but this time I am using a Nano. Will it work on a Nano? And is there anyone who can point me in the direction for the code?
The Pro Micro can act as a USB keyboard/mouse as it has USB HID support builtin (ATMega 32U4) while the Nano (ATMega 328) does not (unless you use a custom firmware).
alto777:
Hmm, not seeing where you describe this issue you are having.
a7
Sorry,
I am getting an error when using the button box sketch i used for the first box i made. And I am not sure why. It says "joystick_'does not name a type: did you mean 'Joystick'"
It is not easy to say as long as you do not show your code.
But, I suspect you are using a library that is supported by the Pro Micro, and not the Nano.
If that is the reason, compilng should succeed if you change board to Leonardo.
(You don't need to have a physical Pro Micro, just change board on the Tools-menu)
You will probably see more errors if you scroll through the "messages-window" in the IDE.
I copied the error message, does this help? I am really new at this, and have created two button boxes with the same code, it worked on one but not the other.
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Micro"
ARDUINO_BUTTON_BOXV2:99:1: error: 'Joystick_' does not name a type; did you mean 'Joystick'?
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
^~~~~~~~~
Joystick
C:\Arduino\libraries\32-FUNCTION-BUTTON-BOX-master\ARDUINO_BUTTON_BOXV2\ARDUINO_BUTTON_BOXV2.ino: In function 'void setup()':
ARDUINO_BUTTON_BOXV2:105:10: error: expected unqualified-id before '.' token
Joystick.begin();
^
C:\Arduino\libraries\32-FUNCTION-BUTTON-BOX-master\ARDUINO_BUTTON_BOXV2\ARDUINO_BUTTON_BOXV2.ino: In function 'void CheckAllButtons()':
ARDUINO_BUTTON_BOXV2:127:20: error: expected unqualified-id before '.' token
Joystick.setButton(buttbx.key*.kchar, 1);*
^* ARDUINO_BUTTON_BOXV2:131:20: error: expected unqualified-id before '.' token
_ Joystick.setButton(buttbx.key*.kchar, 0);_
_ ^_ C:\Arduino\libraries\32-FUNCTION-BUTTON-BOX-master\ARDUINO_BUTTON_BOXV2\ARDUINO_BUTTON_BOXV2.ino: In function 'void CheckAllEncoders()': ARDUINO_BUTTON_BOXV2:162:14: error: expected unqualified-id before '.' token Joystick.setButton(rotaries_.ccwchar, 1); delay(50); Joystick.setButton(rotaries.ccwchar, 0); ^ ARDUINO_BUTTON_BOXV2:162:69: error: expected unqualified-id before '.' token Joystick.setButton(rotaries.ccwchar, 1); delay(50); Joystick.setButton(rotaries.ccwchar, 0); ^ ARDUINO_BUTTON_BOXV2:165:14: error: expected unqualified-id before '.' token Joystick.setButton(rotaries.cwchar, 1); delay(50); Joystick.setButton(rotaries.cwchar, 0); ^ ARDUINO_BUTTON_BOXV2:165:68: error: expected unqualified-id before '.' token Joystick.setButton(rotaries.cwchar, 1); delay(50); Joystick.setButton(rotaries.cwchar, 0); ^ Multiple libraries were found for "Joystick.h" Used: C:\Users\User\Documents\Arduino\libraries\Joystick* * Not used: C:\Users\User\Documents\Arduino\libraries\ArduinoJoystickLibrary-master* exit status 1 *'Joystick' does not name a type; did you mean 'Joystick'? This report would have more information with _"Show verbose output during compilation"* option enabled in File -> Preferences._
Thanks, i figured out that problem, now I have an error in the code i am working on. Not sure why there is an error, its the same code i made for a button box i made previously.
Multiple libraries were found for "Joystick.h" * Used: C:\Users\User\Documents\Arduino\libraries\Joystick* * Not used: C:\Users\User\Documents\Arduino\libraries\ArduinoJoystickLibrary-master*
If you get the error messages shown in #8, you have two libraries for "Joystick.h".
Make sure you have the "right one" in ....\libraries