Arduino coding keyboard on the pi pico?

Hello, I just rencelty saw a video of a guy has gotten the pi pico to run on the arduino IDE and said Thank god because i love arduino and I do like the raspberry pi for other things into i saw the pico and saw i wish it would work on the arduino ide and saw it is somewhat i think.

So my question is the hid keyboard i use for my arduino nano i use as a keyboard that works great. Does anyone know if the same coding would work on the pico? I'm not seeing anyone doing this yet with the arduino ide yet.

Joseph

Other than being made by the same company, who will support all their products with the same focus on learning, the RP2040-based boards like the Pico are completely different from the Raspberry Pi SBCs. So don't expect the Pico to be useful for the same applications as the RPi boards. It's a microcontroller development board, not a computer.

Wish granted. Arduino has added official support for the RPi Pico, using the Mbed OS-based framework of the Nano 33 BLE, Portenta H7, and Nano RP2040 Connect. Just install "Arduino Mbed OS RP2040 Boards" via Boards Manager and then select Tools > Board > Arduino Mbed OS RP2040 Boards > Raspberry Pi Pico from the IDE's menus.

There is also a 3rd party boards platform which takes a more "bare metal" approach:

We will likely need more information before being able to answer your question.

I'm surprised to see you mention HID on an Arduino Nano. Are you talking about the classic ATmega328P-based Arduino Nano?

Hello Sorry if i didn't phrase it correctly. I did get the pi pico working on the arduino ide by watching this guy video here. And that worked great. i did a led blink and hello world serial monitor and it worked.

But when i tried the example sketch USB>KeyBoard>KeybordMessage I get button when i try to assign a button to it. I'm not sure what is wrong. The only thing i can think about the pinout is different. That is why I'm here to seek some help.

Joseph

Please provide a detailed description of what you mean by "I get button".

I'm sorry let me rephrase it again it's hard typing from a cell phone. When i try to assign a button like say A4 or 4 for D4 i get nothing. So no matter what button i tried get nothing from it.

joseph

The Thing is i don't know how to assign GP pins or Gpio pins.

Edit: What I'm trying to do is make a Hid keyboard like i did on my arduino leonardo before but this time using the pi pico.

Joseph

My advice is to split the project up into its individual parts:

  • Write a sketch that prints the digitalRead()value to Serial Monitor. This will allow you to verify you are able to read digital signals from the button.
  • Write a sketch that emulates an arbitrary keypress once every 10 seconds. This will allow you to verify you are able to do keyboard emulation.

Get each part working perfectly before combining them together so that a button press results in a keypress emulation.

As it is right now, it's difficult to know whether the problem is in the button reading or in the HID aspects of the code.

OK, that makes much more sense. The reason I was confused when you said "Arduino Nano" is because the classic Nano does not have native USB capabilities. It is probably possible to do some bit banged emulation like on the digispark, but that is very complex and reported to not be so reliable, so most Arduino people are happy enough to use a microcontroller with easy support for USB things already built-in.

Hello Pert, The problem is i think is the pin mapping. Sense it is using GPIO pins and not a pin mapping of digital and analog pins which arduino uses. I do not know how to use a GPIO pin within the sketch. Here is the image of it.

Joseph

Yes, I suspected the same. This is why I suggested you to start with a very simple sketch for reading from a pin before getting into the complexity of keyboard emulation.

Unfortunately, I don't own a RPi Pico, so I don't have any experience with its pin mapping. I would recommend starting with trying to use the GPIO numbers as Arduino pin numbers. So if you have the button connected to GP2, do this in your sketch:

digitalRead(2);

I can see that the built-in LED is defined as being on Arduino pin 25 in the "Arduino Mbed OS RP2040 Boards" platform, which makes me think that is how it works:

Same for the earlephilhower/arduino-pico platform:

hello Pert, I did aexample DigitalRealSerial With 2 i looekd up the pico pinout for GP2 and 3.3v. I open the serial monitor it read 0 when i pushed the button it displayed a 1. Then when i released the button it went back to zero 0. So that worked.

Joseph

I think i king of figure it out. It wasn't the coding but in fact two problems the wiring and pinout.

First The pinout i was thinking of something totally wrong when it comes to pinout so Pert you pointing me in the right direction.

Second problem is the wiring. When i did the digital read serial I put one pin to 2 and the other to ground and it wasn't working. So when i did one pin to ground and one pin to the 3.3v pin i was able to make it work.

The other problem is when i did a keyboard setup the problem was in the pinout and wiring. The pinout i did for 2 and 3 page up and page down. however when i put the other side of the pins to vcc 3.3v nothing worked. So i thought and tryed instead of VCC 3.3v to use the ground pin and that worked i was able to move the page up and down in the arduino forum.

I know it's not a tipical wiring for a button and i know i need a resistor as i did in the past. Also got debouncing was off. But still to get it working was great. I will work on it more in the morning after sleep its late. Thank you so much perf for pointing me in the right direction.

Joseph

You're welcome. I'm very glad to hear you have had success with the digitalRead()!

Yes pinout and wiring for me needs more attention Because it is not like the avr wiring and pinout.

Joseph