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