#include <Servo.h>
Servo myservo; // create servo object to control a servo
int val1=0;
int val2=0;
int val3=0;
int val4=0;
void setup() {
val4 = 90;
myservo.attach(3); // attaches the servo on pin 9 to the servo object
pinMode(9, OUTPUT);
pinMode(12, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
myservo.write(val4); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
digitalWrite(9, LOW); // leftfrontback
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for a second
digitalWrite(9, HIGH); // frontleftright
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for a second digitalWrite(0, HIGH);
digitalWrite(9, HIGH); // rightbackfront
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(3000);
digitalWrite(9, LOW); // backrightleft
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(3000);
digitalWrite(9, LOW); // backnonedead
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(3000);
}
void loop() {
val1 = digitalRead(17);
val2 = digitalRead(18);
val3 = digitalRead(19);
digitalWrite(9, HIGH); // rightbackfront
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
if(val1==LOW)
{
digitalWrite(9, LOW); // backrightleft
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(5000);
}
if(val2==LOW)
{
digitalWrite(9, HIGH); // frontleftright
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second digitalWrite(0, HIGH);
}
if(val3==LOW)
{
digitalWrite(9, LOW); // leftfrontback
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for a second
digitalWrite(9, HIGH); // frontleftright
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second digitalWrite(0, HIGH);
}
val4=val4+3;
if(val4<22)
{
myservo.write(val4); // sets the servo position according to the scaled value
delay(100); // waits for the servo to get there
}
else
{
for(int i=22;i<1;i-3)
{ myservo.write(i); // sets the servo position according to the scaled value
delay(50);
}
val4=0;
myservo.write(val4); // sets the servo position according to the scaled value
delay(15);
}
}
Servo myservo; // create servo object to control a servo
int val1=0;
int val2=0;
int val3=0;
int val4=0;
void setup() {
val4 = 90;
myservo.attach(3); // attaches the servo on pin 9 to the servo object
pinMode(9, OUTPUT);
pinMode(12, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
myservo.write(val4); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
digitalWrite(9, LOW); // leftfrontback
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for a second
digitalWrite(9, HIGH); // frontleftright
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for a second digitalWrite(0, HIGH);
digitalWrite(9, HIGH); // rightbackfront
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(3000);
digitalWrite(9, LOW); // backrightleft
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(3000);
digitalWrite(9, LOW); // backnonedead
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(3000);
}
void loop() {
val1 = digitalRead(17);
val2 = digitalRead(18);
val3 = digitalRead(19);
digitalWrite(9, HIGH); // rightbackfront
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
if(val1==LOW)
{
digitalWrite(9, LOW); // backrightleft
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, LOW); // turn the LED on (HIGH is the voltage level)
delay(5000);
}
if(val2==LOW)
{
digitalWrite(9, HIGH); // frontleftright
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second digitalWrite(0, HIGH);
}
if(val3==LOW)
{
digitalWrite(9, LOW); // leftfrontback
digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for a second
digitalWrite(9, HIGH); // frontleftright
digitalWrite(12, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(10, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for a second digitalWrite(0, HIGH);
}
val4=val4+3;
if(val4<22)
{
myservo.write(val4); // sets the servo position according to the scaled value
delay(100); // waits for the servo to get there
}
else
{
for(int i=22;i<1;i-3)
{ myservo.write(i); // sets the servo position according to the scaled value
delay(50);
}
val4=0;
myservo.write(val4); // sets the servo position according to the scaled value
delay(15);
}
}
Black book
blackbook1
blackbook2
blackbook3
blackbook4
blackbook5
blackbook6
blackbook7
blackbook8
blackbook9
blackbook10
blackbook2
blackbook3
blackbook4
blackbook5
blackbook6
blackbook7
blackbook8
blackbook9
blackbook10
ppt
Circuit diagram:-