SCHEMATIC
PARTS USED
1.
Arduino UNO
2.
m-m wire
3.
Resistors
4.
LED
5.
Buzzer
6.
Bread Board
CODE
int j;
int i;
void setup() {
// put your setup code here, to run once:
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(4,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for(i=0; i<=30; i++)
{
digitalWrite(5,HIGH); //pinmode 5 high
if(i>=10 && i<20) //if statement for pin mode 5
{
if(i==10)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000); //delay 3 seconds
digitalWrite(5,LOW); //pinmode 5 low
}
else if(i>=20 && i<=30)
{
if(i==20)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000);
}
else
{
if(i==0)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(100);
digitalWrite(5,LOW);
}
digitalWrite(6,HIGH); //pinmode 6 high
if(i>=10 && i<20) //if statement for pinmode 6
{
if(i==10)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000); //delay 3 seconds
digitalWrite(6,LOW); //pinmode 6 low
}
else if(i>=20 && i<=30)
{
if(i==20)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000);
}
else
{
if(i==0)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(100);
digitalWrite(6,LOW);
}
digitalWrite(7,HIGH); //pinmode 7 high
if(i>=10 && i<20) //if statement for pinmode 7
{
if(i==10)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000); //delay 3 seconds
digitalWrite(7,LOW); //pinmode 7 low
}
else if(i>=20 && i<=30)
{
j=0;
if(i==20)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000);
}
else
{
if(i==0)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(100);
digitalWrite(7,LOW);
}
if (j==0) //if statement for shutdown
{
digitalWrite(5,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(1000);
j=1;
}
}
}
PARTS USED
1.
Arduino UNO
2.
m-m wire
3.
Resistors
4.
LED
5.
Buzzer
6.
Bread Board
CODE
int j;
int i;
void setup() {
// put your setup code here, to run once:
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(4,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for(i=0; i<=30; i++)
{
digitalWrite(5,HIGH); //pinmode 5 high
if(i>=10 && i<20) //if statement for pin mode 5
{
if(i==10)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000); //delay 3 seconds
digitalWrite(5,LOW); //pinmode 5 low
}
else if(i>=20 && i<=30)
{
if(i==20)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000);
}
else
{
if(i==0)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(100);
digitalWrite(5,LOW);
}
digitalWrite(6,HIGH); //pinmode 6 high
if(i>=10 && i<20) //if statement for pinmode 6
{
if(i==10)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000); //delay 3 seconds
digitalWrite(6,LOW); //pinmode 6 low
}
else if(i>=20 && i<=30)
{
if(i==20)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000);
}
else
{
if(i==0)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(100);
digitalWrite(6,LOW);
}
digitalWrite(7,HIGH); //pinmode 7 high
if(i>=10 && i<20) //if statement for pinmode 7
{
if(i==10)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000); //delay 3 seconds
digitalWrite(7,LOW); //pinmode 7 low
}
else if(i>=20 && i<=30)
{
j=0;
if(i==20)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(3000);
}
else
{
if(i==0)
{
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
}
delay(100);
digitalWrite(7,LOW);
}
if (j==0) //if statement for shutdown
{
digitalWrite(5,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(1000);
j=1;
}
}
}
No comments:
Post a Comment