Breadboard connection |
//LED_Pattern
#define L1 13
#define L2 12
#define L3 11
#define L4 10
//#define L5 9
//#define L6 8
//#define L7 7
#define buzzer 5
#define buttonPin 6 //the number of the pushbutton pin
int de=150; // delay time
int pattern = 0; // variable for patten
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
// pinMode(L5, OUTPUT);
// pinMode(L6, OUTPUT);
// pinMode(L7, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
pattern++;
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
delay(100);
}
if(pattern==1)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
//digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //1
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
//digitalWrite(L7,LOW); //2
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
//digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
//digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
//digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
//digitalWrite(L5,HIGH);
//digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
//digitalWrite(L7,HIGH); //7
delay(de);
}
if(pattern==2)
{
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
//digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
//digitalWrite(L7,HIGH); //7
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //2
delay(de);
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //1
delay(de);
}
if(pattern==3)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //1
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //2
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,HIGH); //7
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //2
delay(de);
}
if(pattern==4)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,HIGH); //1,7
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //2,6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3,5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
}
if(pattern==5)
{
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3,5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //2,6
delay(de);
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,HIGH); //1,7
delay(de);
}
if(pattern==6)
{
digitalWrite(L1,HIGH);
delay(de);
digitalWrite(L2,HIGH);
delay(de);
digitalWrite(L3,HIGH);
delay(de);
digitalWrite(L4,HIGH);
delay(de);
// digitalWrite(L5,HIGH);
// delay(de);
// digitalWrite(L6,HIGH);
// delay(de);
// digitalWrite(L7,HIGH); //1,7
// delay(de);
// digitalWrite(L7,LOW); //1,7
// delay(de);
// digitalWrite(L6,LOW);
// delay(de);
// digitalWrite(L5,LOW);
// delay(de);
digitalWrite(L4,LOW);
delay(de);
digitalWrite(L3,LOW);
delay(de);
digitalWrite(L2,LOW);
delay(de);
digitalWrite(L1,LOW);
delay(de);
}
if(pattern==7)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,HIGH);
digitalWrite(L3,HIGH);
digitalWrite(L4,HIGH);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,HIGH);
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW);
delay(de);
pattern = 0;
}
}
#define L1 13
#define L2 12
#define L3 11
#define L4 10
//#define L5 9
//#define L6 8
//#define L7 7
#define buzzer 5
#define buttonPin 6 //the number of the pushbutton pin
int de=150; // delay time
int pattern = 0; // variable for patten
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
// pinMode(L5, OUTPUT);
// pinMode(L6, OUTPUT);
// pinMode(L7, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
pattern++;
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);
delay(100);
}
if(pattern==1)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
//digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //1
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
//digitalWrite(L7,LOW); //2
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
//digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
//digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
//digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
//digitalWrite(L5,HIGH);
//digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
//digitalWrite(L7,HIGH); //7
delay(de);
}
if(pattern==2)
{
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
//digitalWrite(L5,LOW);
//digitalWrite(L6,LOW);
//digitalWrite(L7,HIGH); //7
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //2
delay(de);
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //1
delay(de);
}
if(pattern==3)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //1
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //2
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,HIGH); //7
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //2
delay(de);
}
if(pattern==4)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,HIGH); //1,7
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //2,6
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3,5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
}
if(pattern==5)
{
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,HIGH);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //4
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,HIGH);
digitalWrite(L4,LOW);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW); //3,5
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,HIGH);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,LOW); //2,6
delay(de);
digitalWrite(L1,HIGH);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,HIGH); //1,7
delay(de);
}
if(pattern==6)
{
digitalWrite(L1,HIGH);
delay(de);
digitalWrite(L2,HIGH);
delay(de);
digitalWrite(L3,HIGH);
delay(de);
digitalWrite(L4,HIGH);
delay(de);
// digitalWrite(L5,HIGH);
// delay(de);
// digitalWrite(L6,HIGH);
// delay(de);
// digitalWrite(L7,HIGH); //1,7
// delay(de);
// digitalWrite(L7,LOW); //1,7
// delay(de);
// digitalWrite(L6,LOW);
// delay(de);
// digitalWrite(L5,LOW);
// delay(de);
digitalWrite(L4,LOW);
delay(de);
digitalWrite(L3,LOW);
delay(de);
digitalWrite(L2,LOW);
delay(de);
digitalWrite(L1,LOW);
delay(de);
}
if(pattern==7)
{
digitalWrite(L1,HIGH);
digitalWrite(L2,HIGH);
digitalWrite(L3,HIGH);
digitalWrite(L4,HIGH);
// digitalWrite(L5,HIGH);
// digitalWrite(L6,HIGH);
// digitalWrite(L7,HIGH);
delay(de);
digitalWrite(L1,LOW);
digitalWrite(L2,LOW);
digitalWrite(L3,LOW);
digitalWrite(L4,LOW);
// digitalWrite(L5,LOW);
// digitalWrite(L6,LOW);
// digitalWrite(L7,LOW);
delay(de);
pattern = 0;
}
}
Comments
Post a Comment