EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

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
Page #282 background imageLoading...
Page #282 background image
Chapter 27 Solder Circuit Board
282
www.freenove.com ā–ˆ
ā–ˆ support@freenove.com
44
45
46
47
48
49
}
outData(data); //Send the data to 74HC595
}
}
return 0;
}
We can see that this program is different from the previous one. We define an array to modulate different
PWM pulse width for LEDs, so that different LEDs can emit different brightness. Starting from the array index
0, take an array of 8 adjacent numbers as the LED duty cycle and output it at a time. Increases the starting
index number in turn, then it will create a flowing effect.
const int pluseWidth[]={0,0,0,0,0,0,0,0,64,32,16,8,4,2,1,0,0,0,0,0,0,0,0};
By recording the moving time point to control the speed of the movement of index number, namely, control
the flowing speed of flowing water light. Variable moveSpeed saves the time interval of each move, and the
greater the value, the slower the flowing rate. On the contrary, the faster the flowing.
if(millis() - lastMove > moveSpeed) { //speed control
lastMove = millis(); //Record the time point of the move
index++; //move to next
if(index > 15) index = 0; //index to 0
}
Finally, in a ā€œforā€ cycle with i=64, modulate output pulse width of PWM square wave. And the progress, from
the beginning of implementing the for cycle to the end, is a PWM cycle. In the cycle, there is another for cycle
with j=8. And in this cycle, compare the cycle number ā€œiā€ to the value of the array to determine output high
or low level. At last, the data will be sent to 74HC595.
for(i=0;i<64;i++){ //The cycle of PWM is 64 cycles
int8_t data = 0; //This loop of output data
for(j=0;j<8;j++){ //Calculate the output state of this loop
if(i < pluseWidth[index+j]){ //Calculate the LED state according to
the pulse width
data |= 0x01<<j ; //Calculate the data
}
}
outData(data); //Send the data to 74HC595
}

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish