Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
skript:arduinoradar [2016/08/03 16:40] c.jaedicke [Das Arduino Radar] |
skript:arduinoradar [2016/08/03 17:39] (aktuell) c.jaedicke [Etwas zeichnen mit Processing] |
||
---|---|---|---|
Zeile 5: | Zeile 5: | ||
- Servo-Aktuator (Blue Bird) | - Servo-Aktuator (Blue Bird) | ||
- | Schaut im Internet wie ihr die Sensoren bzw. Aktuatoren an den Arduino anschließen könnt. Sobald ihr die Messdaten in einer sinnvollen SI-Einheit auf dem Seriellen Monitor ausgeben könnt bzw. den Servo auf beliebige Positionen steuern könnt, widmet ihr euch dem Datenaustausch zwischen Arduino und Processing. Weitere Aufgaben sind: | + | Schaut im Internet wie ihr die Sensoren bzw. Aktuatoren an den Arduino anschließen könnt. Sobald ihr die Messdaten in einer sinnvollen [[https://de.wikipedia.org/wiki/Internationales_Einheitensystem#SI-Basiseinheiten|SI-Einheit]] auf dem Seriellen Monitor ausgeben könnt bzw. den Servo auf beliebige Positionen steuern könnt, widmet ihr euch dem Datenaustausch zwischen Arduino und Processing. Weitere Aufgaben sind: |
* Montieren der Sensoren auf dem Servo | * Montieren der Sensoren auf dem Servo | ||
* Visualisierung der Daten in Processing | * Visualisierung der Daten in Processing | ||
Zeile 12: | Zeile 12: | ||
<code java> | <code java> | ||
- | int tickRadius; //radius of the ticks | + | int x; |
- | int handPos; //position of the hand in degree | + | |
- | //window origin in the upper left corner | + | |
- | int x_M; //window center in x-direction | + | |
- | int y_M; //window center in y-direction | + | |
void setup() { | void setup() { | ||
//window size in pixel | //window size in pixel | ||
size(700,500); | size(700,500); | ||
- | tickRadius = 200; | + | x = 0; |
- | handPos = 0; | + | |
- | x_M = width/2; | + | |
- | y_M = height/2; | + | |
} | } | ||
void draw() { | void draw() { | ||
- | drawBackground(); | + | //draws a point in the window |
- | drawCenter(); | + | point(x, height/4); |
- | drawTicks(); | + | //draws a line |
- | handPos = drawHand(handPos); | + | line(x, height/2, x-10, 2 * height/4 - 40); |
- | } | + | //draws a circle |
- | + | ellipse(x, 3 * height/4, 10, 10); | |
- | void drawBackground() { | + | //every 10px |
- | // Using only one value with color() | + | x+=10; |
- | // generates a grayscale value. | + | |
- | color c = color(65); // Define 'c' with grayscale value | + | |
- | background(c); // 'c' as background color | + | |
- | } | + | |
- | + | ||
- | void drawCenter() { | + | |
- | color c = color(255, 204, 0); // Define RGB color 'c' | + | |
- | fill(c); // Use color variable 'c' as fill color | + | |
- | noStroke(); // Don't draw a stroke around shapes | + | |
- | ellipse(x_M, y_M, 40, 40); // Draw left circle | + | |
- | } | + | |
- | + | ||
- | void drawTicks() { | + | |
- | color c = color(255, 204, 0); // Define RGB color 'c' | + | |
- | stroke(c); | + | |
- | for(int i = 0; i < 360; i+=4){ | + | |
- | // x = r * cos(phi), y = r * sin(phi) | + | |
- | // use radian measure | + | |
- | point(x_M + tickRadius * cos(PI/180*i), y_M + tickRadius * sin(PI/180*i)); | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | + | ||
- | int drawHand(int handPos) { | + | |
- | color c = color(255, 204, 0); // Define RGB color 'c' | + | |
- | stroke(c); | + | |
- | // x = r * cos(phi), y = r * sin(phi) | + | |
- | // use radian measure | + | |
- | line(x_M, y_M, x_M + tickRadius * cos(PI/180*handPos), y_M + tickRadius * sin(PI/180*handPos)); | + | |
- | // update handPos by one degree | + | |
- | handPos++; | + | |
- | return handPos; | + | |
} | } | ||
</code> | </code> | ||
- | |||
==== Daten vom Arduino mit Processing empfangen ==== | ==== Daten vom Arduino mit Processing empfangen ==== | ||
- | [[techniken:datenaustausch|Datenaustausch zwischen Arduino und Computer]] | + | [[http://www.mintgruen.tu-berlin.de/robotikWiki/doku.php?id=techniken:datenaustausch:processingserialread|Datenaustausch mit Processing]] |