Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ code
- //
- int status = 0;
- void setup()
- {
- pinMode(2, INPUT);
- pinMode(3, INPUT);
- pinMode(4, INPUT);
- pinMode(5, OUTPUT);
- pinMode(6, OUTPUT);
- pinMode(7, OUTPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- int pattern =0; //1,2,3
- int input1 = digitalRead(2);
- int input2 = digitalRead(3);
- int input3 = digitalRead(4);
- Serial.print("Input1 = ");
- Serial.println(input1);
- Serial.print("Input2 = ");
- Serial.println(input2);
- Serial.print("Input3 = ");
- Serial.println(input3);
- if(input1==HIGH)
- {
- pattern = 1;
- }
- else if(input2==HIGH)
- {
- pattern = 2;
- }
- else if(input3==HIGH)
- {
- pattern = 3;
- }
- if(pattern!=0)
- {
- status=pattern;
- }
- Serial.print("pattern = ");
- Serial.println(pattern);
- Serial.print("status = ");
- Serial.println(status);
- ledDance(status);
- }
- void ledDance(int p)
- {
- switch(p)
- {
- case 1: seqOne(); break;
- case 2: seqTwo(); break;
- case 3: seqThree(); break;
- }
- }
- void seqOne()
- {
- digitalWrite(5,HIGH);
- delay(1000);
- digitalWrite(5,LOW);
- delay(1000);
- digitalWrite(6,HIGH);
- delay(1000);
- digitalWrite(6,LOW);
- delay(1000);
- digitalWrite(7,HIGH);
- delay(1000);
- digitalWrite(7,LOW);
- delay(1000);
- }
- void seqTwo()
- {
- digitalWrite(7,HIGH);
- delay(1000);
- digitalWrite(7,LOW);
- delay(1000);
- digitalWrite(6,HIGH);
- delay(1000);
- digitalWrite(6,LOW);
- delay(1000);
- digitalWrite(5,HIGH);
- delay(1000);
- digitalWrite(5,LOW);
- delay(1000);
- }
- void seqThree()
- {
- seqOne();
- seqTwo();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement