Making shortcuts with ARDUINO UNO

I currently have a problem and I can't find the solution, well, I found something, but it doesn't work for me. I explain my problem:

I have a project in mind which is to make a small stream deck for use with shortcuts on the pc. This with ARDUINO UNO R3, I have only been able to get through the IDE program serial letters. But I have not been able to ensure that the device itself can be internally functional with the pc (writing in a .txt per example), wish to make it functional as a normal keyboard. Is there any way for make it possible? I attach the code that I have used.

/* Example code
 * by Eward Hage
 */
uint8_t buf[8] = { 0 };   //Keyboard report buffer

#define PIN_W 4 // Pin for w
#define PIN_A 5 // Pin for a
#define PIN_S 6 // Pin for s
#define PIN_D 7 // Pin for d

void setup() {
  Serial.begin(9600); //Setup Serial communication
  //Set pinmode of Input pins
  pinMode(PIN_W, INPUT);
}

void loop() {
//When button representing W is pressed  
  if (digitalRead(PIN_W) == HIGH) { 
    buf[2] = 26;   // W keycode
    Serial.write("2");
    Serial.write(buf, 8); // Send keypress
    Serial.println("W");
    releaseKey();
  }
}
// Function for Key Release
void releaseKey() 
{
  buf[0] = 0;
  buf[2] = 0;
  Serial.write(buf, 8); // Send Release key  
}

imagen_2021-06-10_203528

I have seen that there is a program called: Flip, I have tried to install and use it, but I have not been able to make it detect the device, it returns a .dll not found (saw a video for how to solve it BUT a lot of people doesn't know how to fix it for Windows x64).

I don't want to flash the Arduino UNO, because I hope there is another way I can do it.

Thanks!

You can learn about the most common way to do it with an Uno here:

Note this only works with the official Arduino Uno or the clones with the ATmega16U2 USB adapter chip. You can't do it with the cheap derivative boards that use the CH340 USB chip.

The best way to do it is to buy an Arduino board that already has the keyboard emulation capability you need. The Uno is simply not the right choice for your project. Although it may be technically possible to do it with the Uno, it will be a very advanced process. With one of the Arduino boards that have native USB capability, it is much easier.

The Arduino Leonardo, Arduino Micro, and Pro Micro are all excellent choices for this project. You also can use one of the more advanced boards like the MKR Zero or Nano 33 IoT, but you might find these a little bit more challenging.

1 Like

@jowmklow, your topic has been moved to a more suitable location on the forum.

The Arduino has a ATMEGA328P-PU (Arduino UNO, R3) integrated, (attached image of the device)

Does it means than I can use the 16u2 as a normal USB AVR? Like a Leonardo? Or Arduino Micro?
It seems I have to program the Arduino and enter bootloader mode. What will happend if I don't make it ok? I mean, is it secure?

That chip does not have native USB capabilities. It is theoretically possible to do "bit banged" USB emulation on it, but that will be very challenging and likely unreliable.

Of more interest ist that little square chip next to the USB socket. That is the ATmega16U2 microcontroller. This chip does have native USB capabilities. So it is easier to use that chip to emulate a keyboard. You can learn how to do that at the link I provided in my last reply.

Yes.

Correct. You need to upload some special firmware to the ATmega16U2 microcontroller. The normal one the Uno comes with is only capable of creating a serial port.

You might get your Uno into a state where you can no longer upload sketches to it. It could always be recovered with enough effort, but you might find it to be a very difficult process.

I don't understand the question. What do you mean by "secure"?

1 Like

I meant that if I change the mode, could I return the device to the original state?

It's unlikely you would get it into a state where it is impossible to recover back to its original state. However, you might get it into a state where it is difficult to recover it back to its original state.

For example, you might find that you are unable to use the DFU programming method like you see in the Atmel Flip tutorials and instead need to use an ISP programmer connected to the ATmega16U2's ICSP header in order to flash the original firmware to it.

2 Likes