Benutzer-Werkzeuge

Webseiten-Werkzeuge


skript:arduinoradar

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
skript:arduinoradar [2016/08/03 15:25]
c.jaedicke
skript:arduinoradar [2016/08/03 17:39] (aktuell)
c.jaedicke [Etwas zeichnen mit Processing]
Zeile 1: Zeile 1:
 ===== Das Arduino Radar ===== ===== Das Arduino Radar =====
 +In drei Teams wird der Bau des Radars vorbereitet: ​
 +  - Ultraschall-Sensor (HC-SR04)
 +  - Infrarot-Sensor (Sharp GP2D12)
 +  - Servo-Aktuator (Blue Bird)
  
-=== Etwas zeichnen mit Processing ===+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 
 +  * Visualisierung der Daten in Processing 
 +==== Etwas zeichnen mit Processing ​====
 Einfache grafische Elemente mit Processing darstellen, ein Beispiel: Einfache grafische Elemente mit Processing darstellen, ein Beispiel:
  
 <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; +  ​= 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); 
 +  ​//every 10px 
 +  x+=10;
 } }
- 
-void drawBackground() { 
-  // Using only one value with color() 
-  // 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 ====
 +[[http://​www.mintgruen.tu-berlin.de/​robotikWiki/​doku.php?​id=techniken:​datenaustausch:​processingserialread|Datenaustausch mit Processing]]
skript/arduinoradar.1470230727.txt.gz · Zuletzt geändert: 2016/08/03 15:25 von c.jaedicke