Was ihr hier sieht ist eine Besondere Eule in einem Computerprogramm welches in Processing geschrieben wurde. Was sie das kann erfahrt ihr gleich !
Die Eule wird von diesem Arduino gesteuert. Das erfolgt mit der Processing serial librarie,
Die mit dem arduino über den serial Port kommuniziert. An den Arduino angeschlossen finden wir einen Temperatur sensor , eine Totodiode und ein Ultraschall sensor.
1. wenn die Temperatur unter 20 grad ist setzt er sich eine Mütze auf.
2. die Augengröße wir durch den Ultraschallsensor bestimmt.
3. Wenn es dunkel wird geht er schlafen
4. wenn mann ihn zu nahe kommt verändert sich die Hintergrundfarbe.
jetzt kommt der processing code
// © tim-carlo 2015 import processing.serial.*; Serial myPort; int val; int an; float vala = 0; int w = 250; int h = 200; int sensor0 = 0; int sensor1 = 0; int sensor2 = 0; int x = 0; float yoff = 0.2; void setup() { size(500, 500); myPort = new Serial(this, "/dev/cu.usbmodem1a21", 9600); myPort.bufferUntil('\n'); } void draw () { if (sensor2 < 21) { mensch(); fill(#DECFAA); ellipse(285, 10, 60, 60); arc(260, 130, 260, 220, PI+0.2, PI*2.05); fill(255); if (sensor0 > 5) { vala = sensor0; ellipse(w-50, h, 60-vala, 60-vala); ellipse(w+50, h, 60-vala, 60-vala); } if (sensor0 < 5) { background(random(0, 255), random(0, 255), random(0, 255)); } if (sensor0 > 50) { ellipse(w-50, h, 20, 20); ellipse(w+50, h, 20, 20); } if (sensor0 > 105) { ellipse(w-50, h, 20, 20); ellipse(w+50, h, 20, 20); } if (sensor1 < 10) { background(0); } println(x + " Entfenungsmesser: " + sensor0 ); println(x + " Fotodiode: " + sensor1); println(x + " Temperatursensor: " + sensor2); x = x + 1; } else if (sensor2 > 27) { mensch(); fill(#F0C149); beginShape(); float xoff = 0; for (float x = 0; x <= width; x += 10) { float y = map(noise(xoff, yoff), 0, 1, 50, 500); vertex(x, y); xoff += 0.06; } yoff += 0.01; vertex(width, height); vertex(0, height); endShape(CLOSE); fill(255); if (sensor0 > 5) { vala = sensor0; ellipse(w-50, h, 60-vala, 60-vala); ellipse(w+50, h, 60-vala, 60-vala); } if (sensor0 < 5) { background(random(0, 255), random(0, 255), random(0, 255)); } if (sensor0 > 50) { ellipse(w-50, h, 20, 20); ellipse(w+50, h, 20, 20); } if (sensor0 > 105) { ellipse(w-50, h, 20, 20); ellipse(w+50, h, 20, 20); } if (sensor1 < 10) { background(0); } println(x + " Entfenungsmesser: " + sensor0 ); println(x + " Fotodiode: " + sensor1); println(x + " Temperatursensor: " + sensor2); x = x + 1; } else { mensch(); if (sensor0 > 5) { vala = sensor0; ellipse(w-50, h, 60-vala, 60-vala); ellipse(w+50, h, 60-vala, 60-vala); } if (sensor0 < 5) { background(random(0, 255), random(0, 255), random(0, 255)); } if (sensor0 > 50) { ellipse(w-50, h, 20, 20); ellipse(w+50, h, 20, 20); } if (sensor0 > 105) { ellipse(w-50, h, 20, 20); ellipse(w+50, h, 20, 20); } if (sensor1 < 10) { background(0); } println(x + " Entfenungsmesser: " + sensor0 ); println(x + " Fotodiode: " + sensor1); println(x + " Temperatursensor: " + sensor2); x = x + 1; } } void serialEvent(Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n'); if (inString != null) { // trim off any whitespace: inString = trim(inString); // split the string on the commas and convert the // resulting substrings into an integer array: int[] sensors = int(split(inString, ",")); // if the array has at least two elements, you know // you got the whole thing. Put the numbers in the // sensor variables: if (sensors.length >=3) { sensor0 = sensors[0]; sensor1 = sensors[1]; sensor2 = sensors[2]; } } } void mensch() { background(#C7CB8E); fill(255); noStroke(); ellipse(250, 250, 300, 400); //beine stroke(#FFFFFF); strokeWeight(5); line(300, 250, 300, 480); line(200, 250, 200, 480); line(300, 480, 325, 480); line(200, 480, 175, 480); //augen fill(#676161); ellipse(w-50, h, 90, 91); ellipse(w+50, h, 90, 91); fill(255); }

Kommentare
Kommentar veröffentlichen