Does the Nano-ARM work as a keyboard?

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
crispin
Posts: 1
Joined: Tue Oct 15, 2019 10:57 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Does the Nano-ARM work as a keyboard?

Post by crispin » Tue Oct 15, 2019 11:04 pm

I'm building a device that sends keyboard presses over USB - would the Nano-ARM work for this? The Arduino Zero seems to have different USB ports for programming it and using it as a keyboard but the Nano-ARM only has the one USB port - does this serve as dual-purpose programming and native or can it only do one?
Thanks.

Bertus Kruger
Site Admin
Posts: 1785
Joined: Wed Feb 03, 2016 10:26 pm
Location: Wellington , New Zealand
Contact:

Re: Does the Nano-ARM work as a keyboard?

Post by Bertus Kruger » Wed Oct 23, 2019 6:32 pm

crispin wrote:
Tue Oct 15, 2019 11:04 pm
I'm building a device that sends keyboard presses over USB - would the Nano-ARM work for this? The Arduino Zero seems to have different USB ports for programming it and using it as a keyboard but the Nano-ARM only has the one USB port - does this serve as dual-purpose programming and native or can it only do one?
Thanks.
Can be done...

https://www.arduino.cc/reference/en/lan ... /keyboard/

The NanoArm has a software bootloader where as the Arduino Zero has the standard USB port and a extra USB port for a programmer/debugger

ericsacchetto
Posts: 1
Joined: Wed Apr 21, 2021 8:08 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Does the Nano-ARM work as a keyboard?

Post by ericsacchetto » Wed Apr 21, 2021 8:27 am

I was trying to accomplish the same goal.
A keypad connected to the NanoARM to send shortcuts to the PC.
Here is the code:

Code: Select all

#include <Keypad.h>
#include "HID-Project.h"


const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {12, 11, 10, 9}; 
byte colPins[COLS] = {8, 7, 6, 5}; 

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  while(!SerialUSB);
  SerialUSB.begin(9600);
  Consumer.begin();

}

void OpenApp(char appAddress)
{
  Keyboard.press(KEY_LEFT_CTRL);
  Keyboard.press(KEY_ESC);
  delay(100);
  Keyboard.releaseAll();
  Keyboard.write('run');
  Keyboard.write(appAddress);
}
  
void loop(){
  char customKey = customKeypad.getKey();
    
  switch (customKey) 
  {
  case '1':
    Consumer.write(MEDIA_PREVIOUS);
    SerialUSB.println("Button 1 pressed");
    break;
  case '2':
    Consumer.write(MEDIA_PLAY_PAUSE);
    SerialUSB.println("Button 2 pressed");
    break;
  case '3':
    Consumer.write(MEDIA_NEXT);
    SerialUSB.println("Button 3 pressed");
    break;
  case 'A':
    OpenApp('C:\Program Files (x86)\Steam\Steam.exe');
    break;
  case '4':
    // statements
    break;
  case '5':
    // statements
    break;
  case '6':
    // statements
    break;
  case 'B':
    // statements
    break;
  case '7':
    // statements
    break;
  case '8':
    // statements
    break;
  case '9':
    // statements
    break;
  case 'C':
    // statements
    break;
  case '*':
    // statements
    break;
  case '0':
    // statements
    break;
  case '#':
    // statements
    break;
  case 'D':
    // statements
    break;
  }
}
I can see the keys being pressed via Serial Monitor but the shortcut is not executed by the PC.
I was wondering if do I need to change the keypad.h and HID-Project.h libraries to use the SerialUSB instead of the Serial function?
Or should I try to use an FTDI module with the NanoARM D0/D1 to provide a new USB to connect to the PC?
Thanks for the help.

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest