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 #119 background imageLoading...
Page #119 background image
119
Chapter 9 Potentiometer & RGBLED
www.freenove.com
support@freenove.com
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
softPwmCreate(ledBluePin,0,100);
pcf8591Setup(pinbase,address); //initialize PCF8591
while(1){
val_Red = analogRead(A0); //read 3 potentiometers
val_Green = analogRead(A1);
val_Blue = analogRead(A2);
softPwmWrite(ledRedPin,val_Red*100/255); //map the read value of
potentiometers into PWM value and output it
softPwmWrite(ledGreenPin,val_Green*100/255);
softPwmWrite(ledBluePin,val_Blue*100/255);
//print out the read ADC value
printf("ADC value val_Red: %d ,\tval_Green: %d ,\tval_Blue: %d
\n",val_Red,val_Green,val_Blue);
delay(100);
}
return 0;
}
In the code, read the ADC value of 3 potentiometers and map it into PWM duty cycle to control the control
3 LEDs with different color of RGBLED, respectively.

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