File: KeyboardSerial.ino

package info (click to toggle)
arduino 1%3A1.0.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 22,476 kB
  • sloc: java: 56,088; cpp: 10,050; ansic: 9,904; makefile: 1,721; xml: 468; perl: 198; sh: 153; python: 62
file content (36 lines) | stat: -rw-r--r-- 759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* 
 Keyboard test
 
 Reads a byte from the serial port, sends a keystroke back.
 The sent keystroke is one higher than what's received, e.g.
 if you send a, you get b, send A you get B, and so forth.
 
 The circuit:
 * none
 
 created 21 Oct 2011
 modified 27 Mar 2012
 by Tom Igoe
 
This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/KeyboardSerial
 */

void setup() {
  // open the serial port:
Serial.begin(9600);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  // check for incoming serial data:
  if (Serial.available() > 0) {
    // read incoming serial data:
    char inChar = Serial.read();
    // Type the next ASCII value from what you received:
    Keyboard.write(inChar+1);
  }  
}