/*countercreated 2011/05/18Sudip ShresthaSulav Timsina*/int count=0;int delay_val=1000;// The setcountup() method runs once, when the sketch startsvoid setup() {// initialize the digital pin as an output:pinMode(12, OUTPUT);pinMode(11, OUTPUT);pinMode(10, OUTPUT);pinMode(9, OUTPUT);pinMode(8, OUTPUT);pinMode(7, OUTPUT);pinMode(6, OUTPUT);}// the loop() method runs over and over again,// as long as the Arduino has powervoid loop(){switch (count) {case 0:digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, LOW);digitalWrite(6, LOW);digitalWrite(10, LOW);digitalWrite(9, HIGH);delay(delay_val);//do something when var equals 1break;case 1:digitalWrite(11, HIGH);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, HIGH);digitalWrite(6, HIGH);digitalWrite(10, HIGH);digitalWrite(9, HIGH);delay(delay_val);//do something when var equals 2break;case 2:digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(8, HIGH);digitalWrite(7, LOW);digitalWrite(6, LOW);digitalWrite(10, HIGH);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;case 3:digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, LOW);digitalWrite(6, HIGH);digitalWrite(10, HIGH);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;case 4:digitalWrite(11, HIGH);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, HIGH);digitalWrite(6, HIGH);digitalWrite(10, LOW);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;case 5:digitalWrite(11, LOW);digitalWrite(12, HIGH);digitalWrite(8, LOW);digitalWrite(7, LOW);digitalWrite(6, HIGH);digitalWrite(10, LOW);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;case 6:digitalWrite(11, LOW);digitalWrite(12, HIGH);digitalWrite(8, LOW);digitalWrite(7, LOW);digitalWrite(6, LOW);digitalWrite(10, LOW);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;case 7:digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, HIGH);digitalWrite(6, HIGH);digitalWrite(10, HIGH);digitalWrite(9, HIGH);delay(delay_val);//do something when var equals 2break;case 8:digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, LOW);digitalWrite(6, LOW);digitalWrite(10, LOW);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;case 9:digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(8, LOW);digitalWrite(7, LOW);digitalWrite(6, HIGH);digitalWrite(10, LOW);digitalWrite(9, LOW);delay(delay_val);//do something when var equals 2break;}if (count > 9){count=0;//action A}else{count=count+1;// action B}}
Wednesday, May 18, 2011
Simple 1 bit 7-segment LED counter
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment