Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : AttValue: " or ' expected in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): lor: #fff; color: #000; }
| G in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : AttValue: " or ' expected in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): tr> | G | G | GGo in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : AttValue: " or ' expected in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): rif size=10>GoGoGoGoo in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : AttValue: " or ' expected in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): 5f4>GooGooGoooog in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : AttValue: " or ' expected in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): 335>oogoogoogogl in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : AttValue: " or ' expected in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): c05>oglogloglgle in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Opening and ending tag mismatch: html line 1 and font in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): =#4285f4>gle in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Extra content at the end of the document in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): =#4285f4>gle in /app/components/com_wawerko/controllers/show.php on line 937
Warning: SimpleXMLElement::__construct(): ^ in /app/components/com_wawerko/controllers/show.php on line 937
Schritt 5 / 7 - Programm abändern
Um das Rotary Poti Bricklet in das Projekt aufzunehmen wird nun das Programm so abgeändert, dass die Position des Potentiometers die Geschwindigkeit des Motors bestimmt. Das abgeänderte Programm sieht wie folgt aus.
Die Zeilen 4-7 sind die typische Konfiguration, die UIDs müssen die der verwendeten Bricks und Bricklets sein. Die Zeilen 22-27 erstellen die IP Connection zum Brick Daemon. Die Brick und Bricklet Objekte werden erzeugt. Das Rotary Poti
Bricklet wird so konfiguriert, das die Funktion cb_position jedes Mal aufgerufen wird wenn sich die Position des Potentiometers ändert. Zeile 29 stellt diesen Callback so ein, dass er mit einer Periode von 50ms ausgelöst wird wenn sich die
Position ändert. Wenn sich die Position nicht ändert werden keine Callbacks ausgelöst. Dieses Vorgehen ist effizient, es wird nur die unbedingt notwendige USB Bandbreite verwendet. Die Callback Funktion wird in Zeile 30 registriert. cb_position ist in den Zeilen 16-19 definiert, es setzt eine neue Geschwindigkeit für den Motor abhängig von der aktuelle Position des Potentiometers. Die Zeilen 32-33 schalten die Motorsteuerung ein und setzen die Beschleunigung auf Maximum. Dadurch kann die Motorgeschwindigkeit den Änderungen der Potentiometerposition direkt folgen. Die Zeile 35-36 sorgt dafür, dass das Programm weiter läuft bis die Enter Taste gedrückt wird. Der Motor wird danach abgeschaltet.
weiter mit: Stapel bauen ⇒
Einkaufsliste
Material:
-
1 DC-Brick
-
1 Brick Daemon
-
1 Brick Viewer
-
5 Batterien (2700 mAh)
-
1 Batteriehalter
-
1 Servomotor
-
USB-Kabel
-
1 Rotary Poti Bricklet
-
1 Master-Brick
Redaktionstipps
|
|
|
|
|
|
|
Kommentare