Pro Micro with mouse and keyboard emulation

Have questions about a SparkFun product or board? This is the place to be.

Moderators: phalanx, TS-Tim

Post Reply
stebrick
Posts: 6
Joined: Sat Nov 03, 2018 5:49 am

Pro Micro with mouse and keyboard emulation

Post by stebrick » Sat Nov 03, 2018 5:55 am

Dear Guys, I’m using PROMICRO 5V-16MHz to emulate both an usb mouse and keyboard..It works good but when I send some character keyboard or mouse movement by usb connected to a PC, the promicro board always turn on/off the TXLED pin. This is a problem for me because I need to use this pin as a digital output to drive a relays. Generally I want to use What could I do to separate the behaviour of TXLED from the keyboard and mouse functions?? need help :o ..best regards..

paulvha
Posts: 273
Joined: Sat Nov 11, 2017 2:39 am

Re: Pro Micro with mouse and keyboard emulation

Post by paulvha » Sun Nov 04, 2018 4:05 am

Do you really use all the 18 already that you want to switch of TXLED?

stebrick
Posts: 6
Joined: Sat Nov 03, 2018 5:49 am

Re: Pro Micro with mouse and keyboard emulation

Post by stebrick » Sun Nov 04, 2018 5:43 am

Yes, I use all the pins and also an I2c i/o expander! But in particular I need txled and other to drive some relays.. Do you know how to disable txled when promicro is sending something as keyboard/mouse by USB??

paulvha
Posts: 273
Joined: Sat Nov 11, 2017 2:39 am

Re: Pro Micro with mouse and keyboard emulation

Post by paulvha » Sun Nov 04, 2018 11:13 am

wow.. maybe you should take a board with more connections (like a MEGA2560).

It expect it will require a software change in the board library (pins.h) and I can look into that tomorrow. I don't have this board but In the end (and beginning) it is only software. Just be aware that the output for the TXLED ( D17/ PB0) is not available on the 18 pin connection and will require on-board soldering of a connection

stebrick
Posts: 6
Joined: Sat Nov 03, 2018 5:49 am

Re: Pro Micro with mouse and keyboard emulation

Post by stebrick » Sun Nov 04, 2018 1:42 pm

Ok paulvha thanks, any helps are useful.. I use atmega32u4 because of its small factor..

teprojects1
Posts: 51
Joined: Sat Jan 21, 2017 1:28 am
Location: Lahore
Contact:

Re: Pro Micro with mouse and keyboard emulation

Post by teprojects1 » Mon Nov 05, 2018 2:02 am

I have read this great tutorial on USB Pinout , I think that will help.

paulvha
Posts: 273
Joined: Sat Nov 11, 2017 2:39 am

Re: Pro Micro with mouse and keyboard emulation

Post by paulvha » Mon Nov 05, 2018 6:49 am

The best I could find, but not able to test as I do not have a Pro-micro, is in the file <arduino_install_dir>/ packages/Sparkfun/hardware/avr/1.1.12/variants/promicro/pins_arduino.h. At least on my Ubuntu system, you will have to look for similar structure on your PC.

In there is a definition of switching off the TX led : #define TXLED0 PORTD |= (1<<5)
AND switching on : #define TXLED1 PORTD &= ~(1<<5).
The TXled is connected to to PD5.

If you comment those 2 definition out and try to recompile your sketch it will fail as USBcore.cpp is expecting those. Try to change the definitions to PORTD6, as that is not used on the pro-micro and recompile /upload the sketch :
#define TXLED0 PORTD |= (1<<6)
#define TXLED1 PORTD &= ~(1<<6)

In the same file there is also : #define LED_BUILTIN_TX 30. Pin 30 is mapped to PD5 in the structures underneath and you should not change. This LED_BUILTIN_TX is normally a global variable that one can use in a sketch ( e.g. digitalwrite (LED_BUILTIN_TX, HIGH)

regards
Paul

stebrick
Posts: 6
Joined: Sat Nov 03, 2018 5:49 am

Re: Pro Micro with mouse and keyboard emulation

Post by stebrick » Mon Nov 05, 2018 10:35 am

Hi Paul many thanks to your suggestion.. I will try as soon as possible and will come back with the results..

stebrick
Posts: 6
Joined: Sat Nov 03, 2018 5:49 am

Re: Pro Micro with mouse and keyboard emulation

Post by stebrick » Thu Nov 08, 2018 2:20 am

Hi Paul, you are great!!
Your suggestion works perfectly!
Many thanks!!!!!
Best regards

paulvha
Posts: 273
Joined: Sat Nov 11, 2017 2:39 am

Re: Pro Micro with mouse and keyboard emulation

Post by paulvha » Thu Nov 08, 2018 2:53 am

Good to hear. Opposite to my earlier remark that the TX led is connected to D17/PB0, the TX led is actually connected to pin 22 (PD5) or just use the LED_BUILTIN_TX variable in your code. On D17/PB0 the RX led is connected. (I misread the schematics)

stebrick
Posts: 6
Joined: Sat Nov 03, 2018 5:49 am

Re: Pro Micro with mouse and keyboard emulation

Post by stebrick » Sat Nov 10, 2018 5:38 am

Yes you are right.. I also tested promicro with an I/O expander MCP23017 via I2C connection.. It works great to add up 16 I/O to promicro board.. It's easy to set up with wire.h library.. Maybe it could interest in this solution :)

Post Reply