I'm looking to send info (string or int would do) out of the Arduino Uno into the computer.
For example, press a button, the computer receives a message.
Simply using Keyboard.print("msg"); looks to be the most simple method, however, it seems the Arduino Uno doesn't support the Keyboard class. (I can't find a simple workaround on the web)
The next best think I could find is UDP via the EthernetUdp class. But this seems a bit overkill when simply trying to send a message to the computer when a button is pressed.
The other option seems to be purchasing an Arduino Leonardo.
Does anyone know of a way to send a simple message to the computer using the Arduino Uno? Preferably a string as a keyboard stroke but I'm open to anything.
Most people use Serial to communicate with a PC host. The PC treats the UNO as a USB Serial port. That is how the Arduino software communicates with the bootloader.
Very simple serial code that echoes back to the pc what was sent from the pc.
// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
String readString;
void setup() {
Serial.begin(9600);
Serial.println("serial test 0021"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(2); //delay to allow byte to arrive in input buffer
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
readString="";
}
}