EasyManua.ls Logo

Freenove Ultimate Starter Kit

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
203
Chapter 18 74HC595 & 7-segment display.
www.freenove.com
support@freenove.com
Finally, in the main function, configure all the GPIO, and set the timer function.
pinMode(dataPin,OUTPUT); //set the pin connected to74HC595 for output mode
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
//set the pin connected to 7-segment display common end to output mode
for(i=0;i<4;i++){
pinMode(digitPin[i],OUTPUT);
digitalWrite(digitPin[i],LOW);
}
signal(SIGALRM,timer); //configure the timer
alarm(1); //set the time of timer to 1s
In the while cycle, make the digital display variable counter value. The value will change in function timer (),
so the content displayed by 7-segment display will change accordingly.
while(1){
display(counter); //display number counter
}

Table of Contents