/*Write the code to make sure that whenever the horn reach pos 180 it needs to go back to position 0
and change the color of horn to yellow*/
#include <Servo.h>
Servo myservo;
int pos=0;
void setup() {
// put your setup code here, to run once:
myservo.attach(9);
pinMode(8, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Create a if condition that if the pos value becomes greater the 180 then the pos will be reset to 0
if(pos == 180) {
pos = 0;
}
if (pos < 90) {
digitalWrite(8, LOW);
noTone(8);
} else if (pos > 90) {
Serial.println("MM");
digitalWrite(8, HIGH);
tone(8, 262, 250);
}
delay(100);
pos = pos +1;
myservo.write(pos);
}