57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
/* Sweep
|
|
by BARRAGAN <http://barraganstudio.com>
|
|
This example code is in the public domain.
|
|
|
|
modified 28 May 2015
|
|
by Michael C. Miller
|
|
modified 8 Nov 2013
|
|
by Scott Fitzgerald
|
|
|
|
http://arduino.cc/en/Tutorial/Sweep
|
|
*/
|
|
|
|
#include <Servo.h>
|
|
|
|
Servo linkeAugenbraue;
|
|
Servo rechteAugenbraue; // create servo object to control a servo
|
|
// twelve servo objects can be created on most boards
|
|
|
|
|
|
|
|
void setup() {
|
|
myservo.rechteAugenbraue(D1);
|
|
myservo.linkeAugenbraue(D4); // attaches the servo on GIO2 to the servo object
|
|
pinMode(D2, INPUT_PULLUP);
|
|
pinMode(D3, INPUT_PULLUP);
|
|
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop() {
|
|
if (istTasterGedrueckt(D2)) {
|
|
linkeAugenbraue.write(90);
|
|
rechteAugenbraue.write(90);
|
|
Serial.writeln("Vorwärts");
|
|
}
|
|
if (istTasterGedrueckt(D3)) {
|
|
linkeAugenbraue.write(0);
|
|
rechteAugenbraue.write(0);
|
|
Serial.writeln("Rückwärts");
|
|
}
|
|
|
|
debug();
|
|
|
|
}
|
|
void debug(){
|
|
Serial.write("Spannung auf linker Augenbraue: ")
|
|
Serial.writeln(D4);
|
|
Serial.write("Spannung auf rechter Augenbraue: ")
|
|
Serial.writeln(D1);
|
|
delay(200);
|
|
}
|
|
bool istTasterGedrueckt(int taster) {
|
|
return digitalRead(taster) == LOW;
|
|
}
|
|
|
|
|