for(val=255; val>0; val--)
{
analogWrite(11, val);
analogWrite(10, 255-val);
analogWrite(9, 128-val);
delay(1);
}
for(val=0; val<255; val++)
{
analogWrite(11, val);
analogWrite(10, 255-val);
analogWrite(9, 128-val);
delay(1);
}
Serial.println(val, DEC);
}
//////////////////////////////////////////////////////////
Result
Directly copy the above code into arduino IDE, and click upload
can see a full-color LED
*******************************************************************************
Project 11: Analog value reading
Introduction
In this experiment, we will begin the learning of analog I/O interfaces. On an Arduino, there are 6
analog interfaces numbered from 0 to 5. These 6 interfaces can also be used as digital ones
numbered as 14-19. After a brief introduction, let's begin our project. Potentiometer used here is a
typical output component of analog value that is familiar to us.
Hardware required
Potentiometer *1
Breadboard*1
Breadboard jumper wires * several
Circuit connection
In this experiment, we will convert the resistance value of the potentiometer to analog ones and
display it on the screen. This is an application we need to master well for our future experiments.
keyestudio
www.keyestudio.cc
, wait a few seconds, you
50
Need help?
Do you have a question about the ARDUINO maker learning kit and is the answer not in the manual?