ProMicro Receiving to Serial Port Issue

Hello everyone :slight_smile: I'm newbie with arduino altough I have some experinces with programing. I'm using accelerometer connected to my ProMicro to emulate a joystick. I also want to send a single character through serial port via Matlab but it doesn't receive anything (in other projects it worked). My theory is that ProMicro is too busy sending to port and it's blocking the receiving. I looked through the forum and tried several metods to clear the buffer but nothing worked (maybe it was a longshot and I misunderstood the principle of the buffer :smiley: ). Do you have any idea how to handle this?

P.S. uhel_x and uhel_y are angels of tilt and rotation
P.P.S the if part in the beginning of the loop is ,,under construction".

joystick_xy_zakladni_software.ino (4.99 KB)

I am not familiar with the libraries you are using but it is almost certainly your two large delay()s that are upsetting things. The delay() function blocks everything else from happening.

Have a look at how millis() is used to manage timing without blocking in Several things at a time

...R

Delays are there just for testing. The condition for the first ,,if" is never true (none of the characters were recieved altough it should have).

Are you using the ProMicro to pretend to a PC that it is a joystick? If so the normal serial communication between the PC and the Arduino will be disabled.

If you have a USB-TTL cable you could connect your PC to the Pro Micro's Serial1 port (pins 0 and 1).

...R

Yes, I'm using it to pretend that it is a joystick exactly like you said. I don't have TTL USB cable. Is there another way?

Michal46:
I don't have TTL USB cable. Is there another way?

Not as far as I know. They are not expensive.

...R

Thanks for the help, I appreciate it :slight_smile: I will solve the problem other way. I am gonna communicate with the Arduino before I call the function for the joystick emulation. That should be okay.