Untitled
unknown
plain_text
4 years ago
1.2 kB
6
Indexable
//#include <ServoEasing.h>
int laserPin = 10;
const int buzzer = 11; //buzzer to arduino pin 11
#include <Servo.h>
Servo PanServo;
Servo TiltServo;
int pos = 0;
int dur = 10;
void setup() {
// put your setup code here, to run once:
pinMode(laserPin, OUTPUT);
PanServo.attach(9);
TiltServo.attach(8);
pinMode(buzzer, OUTPUT); // Set buzzer - pin 11 as an output
}
void loop() {
digitalWrite(laserPin, LOW);
TiltServo.write(140);
for (pos = 0; pos <= 60; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
PanServo.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
// tone(buzzer, 500); // Send 1KHz sound signal...
// delay(200); // ...for 1 sec
// noTone(buzzer); // Stop sound...
digitalWrite(laserPin, HIGH);
for (pos = 60; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
PanServo.write(pos); // tell servo to go to position in variable 'pos'
delay(20); // waits 15ms for the servo to reach the position
}
// put your main code here, to run repeatedly:
}Editor is loading...