Reputation: 149
I have a problem, I have to control a PWM of the ATMEGA 1280 with the USART pressing the keys on my computer. I can control that, using the ASCII keys and controlling the PWM. The problem is that they're asking to use the arrow keys, now the thing is that arrow keys doesn't have ASCII values, and I don't have the ATMEGA 1280 right now at my disposal. I don't know what value compare with the received value from the arrow key. Somebody has an idea?
Upvotes: 3
Views: 2026
Reputation: 682
You need to use terminal emulator like Putty or other terminal emulation software. If you need handle arrow keys use control escape sequences.
So if you need to handle UP arrow key and after UP key is pressed you will receive to UART ASCII sequence: "ESC 1 A". ESC is 0x1B in ASCII. Other chars just regular ASCII chars. You will find other sequences in page which I provided. You need to parse sequences and you will get all keys.
Upvotes: 5
Reputation: 945
The cursor keys are not part of the standard ASCII character set, so they do not generate a character that can be sent over a UART...
Extended keys can be read via their scan code (Google "PC scan codes") you might be luck that your terminal program is sending the scan codes for non-ascii characters, but these are 2-byte sequences so you're probably ignoring them if you are getting them.
Upvotes: 2