76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
/* Sweep
|
|
by BARRAGAN <http://barraganstudio.com>
|
|
This example code is in the public domain.
|
|
|
|
modified 8 Nov 2013
|
|
by Scott Fitzgerald
|
|
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
|
|
*/
|
|
|
|
#include <Servo.h>
|
|
|
|
Servo linkeAugenbraue;
|
|
Servo rechteAugenbraue; // create servo object to control a servo
|
|
// twelve servo objects can be created on most boards
|
|
|
|
int pos = 0; // variable to store the servo position
|
|
int LINKES_AUGE_DEFAULT = 50;
|
|
int RECHTES_AUGE_DEFAULT = 40;
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
linkeAugenbraue.attach(10); // attaches the servo on pin 9 to the servo object
|
|
rechteAugenbraue.attach(9);
|
|
pinMode(11, INPUT_PULLUP);
|
|
pinMode(12, INPUT_PULLUP);
|
|
start();
|
|
}
|
|
|
|
void start(){
|
|
int origin = linkeAugenbraue.read();
|
|
Serial.println(linkeAugenbraue.read());
|
|
if(origin > LINKES_AUGE_DEFAULT){
|
|
for(int i = origin; i>= LINKES_AUGE_DEFAULT; i--){
|
|
linkeAugenbraue.write(i);
|
|
delay(15);
|
|
}
|
|
}
|
|
if(origin < LINKES_AUGE_DEFAULT){
|
|
for(int i = origin; i<= LINKES_AUGE_DEFAULT; i++){
|
|
linkeAugenbraue.write(i);
|
|
delay(15);
|
|
}
|
|
}
|
|
origin = rechteAugenbraue.read();
|
|
Serial.println(rechteAugenbraue.read());
|
|
if(origin > RECHTES_AUGE_DEFAULT){
|
|
for(int i = origin; i>= RECHTES_AUGE_DEFAULT; i--){
|
|
rechteAugenbraue.write(i);
|
|
delay(15);
|
|
}
|
|
}
|
|
if(origin < RECHTES_AUGE_DEFAULT){
|
|
for(int i = origin; i<= RECHTES_AUGE_DEFAULT; i++){
|
|
rechteAugenbraue.write(i);
|
|
delay(15);
|
|
}
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
angry();
|
|
delay(2000);
|
|
start();
|
|
delay(2000);
|
|
}
|
|
void angry(){
|
|
for(int i = LINKES_AUGE_DEFAULT; i >= 0; i--){
|
|
linkeAugenbraue.write(i);
|
|
rechteAugenbraue.write(80-i);
|
|
delay(15);
|
|
}
|
|
|
|
}
|
|
|
|
bool tasterGedrueckt(int taste) {
|
|
return digitalRead(taste) == LOW;
|
|
} |