CLICK TITLE FOR MORE INFORMATION
Again, another Arduino project from me! But this time, I'll use a 7 segment LED ,a 74HC595 Shift Register and of course an Arduino Board. This project is designed to count-up relevant to the sketch.
7 Segment LED |
74HC595 |
And here's the sketch:
int data=11;
int clock=12;
int latch=8;
int no=0;
int time;
int alp;
int a=B01111110;
int b=B00010010;
int c=B10111100;
int d=B10110110;
int e=B11010010;
int f=B11100110;
int g=B11101110;
int h=B00110010;
int i=B11111110;
int j=B11110110;
void setup(){
pinMode(data,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(latch,OUTPUT);
}
void loop(){
time=millis()/1000;
if(time++){
no++;
}
if(no==10){
no=0;
}
if(no==0){
alp=a;
}
if(no==1){
alp=b;
}
if(no==2){
alp=c;
}
if(no==3){
alp=d;
}
if(no==4){
alp=e;
}
if(no==5){
alp=f;
}
if(no==6){
alp=g;
}
if(no==7){
alp=h;
}
if(no==8){
alp=i;
}
if(no==9){
alp=j;
}
digitalWrite(latch,LOW);
shiftOut(data,clock,LSBFIRST,alp);
digitalWrite(latch,HIGH);
delay(900);
}
Remember! Upload the sketch below to reset the 74HC595 after you're finished with it!
int data=11;
int clock=12;
int latch=8;
void setup(){
pinMode(data,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(latch,OUTPUT);
}
void loop(){
digitalWrite(latch,LOW);
shiftOut(data,clock,LSBFIRST,B00000000);
digitalWrite(latch,HIGH);
}
Last but not least! The video of the project! Enjoy!
Don't know how it works? Just comment below and I'll explain it to you!
by Weng Fei
can you make it counts up with push button?