Hallo zusammen,
ich bin ein absoluter Frischling in Sachen uC's. Ich möchte mich jedoch
in Zukunft verbessern. Ich habe vermutlich eine sehr einfache Frage, auf
die ich jedoch in Google usw. keine Antwort finden konnte. Ich hoffe
jemand kann mir dabei weiterhelfen.
Und zwar möchte ich einen Text per Knopfdruck ausgeben lassen, dazu
nutze ich folgenden Beispiel Code:
1 | /*
|
2 | Keyboard Message test
|
3 |
|
4 | For the Arduino Leonardo and Micro.
|
5 |
|
6 | Sends a text string when a button is pressed.
|
7 |
|
8 | The circuit:
|
9 | - pushbutton attached from pin 4 to +5V
|
10 | - 10 kilohm resistor attached from pin 4 to ground
|
11 |
|
12 | created 24 Oct 2011
|
13 | modified 27 Mar 2012
|
14 | by Tom Igoe
|
15 | modified 11 Nov 2013
|
16 | by Scott Fitzgerald
|
17 |
|
18 | This example code is in the public domain.
|
19 |
|
20 | http://www.arduino.cc/en/Tutorial/KeyboardMessage
|
21 | */
|
22 |
|
23 | #include "Keyboard.h"
|
24 |
|
25 | const int buttonPin = 4; // input pin for pushbutton
|
26 | int previousButtonState = HIGH; // for checking the state of a pushButton
|
27 | int counter = 0; // button push counter
|
28 |
|
29 | void setup() {
|
30 | // make the pushButton pin an input:
|
31 | pinMode(buttonPin, INPUT);
|
32 | // initialize control over the keyboard:
|
33 | Keyboard.begin();
|
34 | }
|
35 |
|
36 | void loop() {
|
37 | // read the pushbutton:
|
38 | int buttonState = digitalRead(buttonPin);
|
39 | // if the button state has changed,
|
40 | if ((buttonState != previousButtonState)
|
41 | // and it's currently pressed:
|
42 | && (buttonState == HIGH)) {
|
43 | // increment the button counter
|
44 | counter++;
|
45 | // type out a message
|
46 | Keyboard.print("You pressed the button ");
|
47 | Keyboard.print(counter);
|
48 | Keyboard.println(" times.");
|
49 | }
|
50 | // save the current button state for comparison next time:
|
51 | previousButtonState = buttonState;
|
52 | }
|
Das funktioniert soweit ganz gut, jedoch möchte ich einen Bindestrich
und einen Doppelpunkt ebenfalls ausgeben mit :
Keyboard.print("view-source:");
Jedoch erhalte ich dabei die Ausgabe:
viewßsourceÖ
Ich nehme an, dass dabei die US-Tastatur herangezogen wird und ich daher
ß und Ö erhalte anstatt - und : .
Leider weiß ich nicht wie ich es formulieren muss, damit ich meine
geschünschte Ausgabe erhalte.
Sorry falls meine Frage sehr dumm ist.
Beste Grüße
Katja :)