Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led1=2;
- int led2=3;
- int led3=4;
- int led4=5;
- int Dec;
- int Bin;
- void setup() {
- pinMode(led1,OUTPUT);
- pinMode(led2,OUTPUT);
- pinMode(led3,OUTPUT);
- pinMode(led4,OUTPUT);
- }
- void loop() {
- for(Dec=0;Dec<=16;Dec++){
- delay(1000);
- if(Dec==0){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==1){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==2){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==3){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- else if(Dec==4){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==5){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==6){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==7){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- else if(Dec==8){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==9){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==10){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==11){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- else if(Dec==12){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==13){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==14){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==15){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- }
- //Down count
- for(Dec=16;Dec>=0;Dec--){
- delay(1000);
- if(Dec==0){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==1){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==2){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==3){
- digitalWrite(led1,0);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- else if(Dec==4){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==5){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==6){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==7){
- digitalWrite(led1,0);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- else if(Dec==8){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==9){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==10){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==11){
- digitalWrite(led1,1);
- digitalWrite(led2,0);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }
- else if(Dec==12){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,0);
- }
- else if(Dec==13){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,0);
- digitalWrite(led4,1);
- }
- else if(Dec==14){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,0);
- }
- else if(Dec==15){
- digitalWrite(led1,1);
- digitalWrite(led2,1);
- digitalWrite(led3,1);
- digitalWrite(led4,1);
- }}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement