Arduino/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Arduino/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | *(Arduino only)* | |
| 2 | + | ||
| 3 | + | # Arduino | |
| 4 | + | ||
| 5 | + | ## Kommunikation mit einem Arduino | |
| 6 | + | ||
| 7 | + | Dieses kleine Beispiel demonstriert eine Kommunikation mit einem Arduino.\ | |
| 8 | + | Der Arduino Sketch in C++ wurde in der Arduino-IDE erstellt. | |
| 9 | + | ||
| 10 | + | ### Arduino Sketch | |
| 11 | + | ||
| 12 | + | Dieser Sketch wandelt alle eingegangenen Buchstaben in Gross-Buchstaben um, ausgenommen Umlaute. Wie man einen Arduino mit C++ programmiert, siehe Arduino-Seite: | |
| 13 | + | ||
| 14 | + | - [Arduino Tutorial](https://www.arduino.cc/en/Tutorial/BuiltInExamples) | |
| 15 | + | ||
| 16 | + | \ | |
| 17 | + | ||
| 18 | + | ``` cpp | |
| 19 | + | #include <Arduino.h> | |
| 20 | + | ||
| 21 | + | void setup() { | |
| 22 | + | Serial.begin(9600); | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | void loop() { | |
| 26 | + | while (Serial.available() > 0) { | |
| 27 | + | char ch = Serial.read(); | |
| 28 | + | if ((ch >= 97) and (ch <= 122)) { | |
| 29 | + | ch -= 32; // In Grossbuchstaben umwandeln. | |
| 30 | + | } | |
| 31 | + | Serial.print(ch); | |
| 32 | + | } | |
| 33 | + | } | |
| 34 | + | ``` | |
| 35 | + | ||
| 36 | + | ### FPC Programm | |
| 37 | + | ||
| 38 | + | Dieses Mini-Programm sendet Zeichen an den COM-Port, an welchen der Arduino angeschossen ist. Der Arduino wandelt dabei die Zeichen in Grossbuchstaben um. | |
| 39 | + | ||
| 40 | + | ``` pascal | |
| 41 | + | program Project1; | |
| 42 | + | uses | |
| 43 | + | Serial, // Für Serielle-Kommunikation. | |
| 44 | + | Crt; // Für Tastatur-Eingabe und Delay. | |
| 45 | + | var | |
| 46 | + | serHandle: TSerialHandle; // Handle für COM-Port. | |
| 47 | + | ch: char; | |
| 48 | + | ||
| 49 | + | begin | |
| 50 | + | serHandle := SerOpen('/dev/ttyUSB0'); // Bei Windows 'COMx' // COM-Port öffnen. | |
| 51 | + | SerSetParams(serHandle, 9600, 8, NoneParity, 1, []); | |
| 52 | + | ||
| 53 | + | repeat | |
| 54 | + | ch := ReadKey; | |
| 55 | + | if ch >= #32 then begin | |
| 56 | + | SerWrite(serHandle, ch, 1); // Zeichen senden. | |
| 57 | + | ch := #0; // Zeichen auf #0 setzen. | |
| 58 | + | Delay(10); // Kleine Verzögerung. | |
| 59 | + | SerRead(serHandle, ch, 1); // Zeichen empfangen. | |
| 60 | + | Write(ch); // Zur Überprüfung auf Bildschirm ausgeben. | |
| 61 | + | end; | |
| 62 | + | until ch = #27; // Bei <ESC> abbrechen. | |
| 63 | + | ||
| 64 | + | SerClose(serHandle); // COM-Port schliessen. | |
| 65 | + | end. | |
| 66 | + | ``` | |
| 67 | + | ||
| 68 | + | ## Arduino mit FPC programmieren | |
| 69 | + | ||
| 70 | + | Es ist auch möglich den Arduino direkt mit Lazarus zu programmieren, siehe dazu: | |
| 71 | + | ||
| 72 | + | - [[AVR Embedded Tutorial/de|AVR-Tutorial]] | |
| 73 | + | - [[AVR Embedded Tutorial - Entry Lazarus and Arduino/de|Lazarus für AVR einrichten]] | |
| 74 | + | ||
| 75 | + | Autor: Mathias | |
| 76 | + | ||
| 77 | + | --- | |
| 78 | + | *From the Free Pascal wiki, page "Arduino/de", as it stood on 2018-05-01 after a change by Mathias, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 79 | + | Category: AVR | |
| 80 | + | Category: Arduino | |
| 81 | + | Category: Embedded |
