[vc_row][vc_column][vc_column_text]In this circuit, you will use a potentiometer. It also called adjustable resistance.When it is connected to 5V via two external pins, the pin in the middle portion, according to the knob on the potentiometer output voltage of 0 – 5V. A potentiometer can achieve a perfect demonstration of the different voltage distribution circuit. Voltage is allocated proportionally to the resistor between the middle of the pin and pin grounded. In this circuit, you will learn how to use a potentiometer to control the brightness of an LED lamp.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Parts list” tab_id=”1393916157-1-18″][vc_column_text]1 one potentiometer
2 one yellow LED lights
3.one 330 ohm resistor
4 six wires
[/vc_column_text][/vc_tab][vc_tab title=”Digital VS Analog ” tab_id=”1393916157-2-54″][vc_column_text]If you look at the back of the pcDuino board, there are a lot of interface, some is digital, some simulation (A0 to A5). Their difference in where? What’s the difference between them?
Many devices you will connect , such as LED lights and buttons , there are only two possible states: on and off , or for pcDuino board , they are” high” ( 5 volts ) and “low” ( 0 volts ) . The digital interface of pcDuino board to receive and send the signal from the outside is very useful , even can achieve some analog dimming ( turn on and turn off the LED lamp quickly) and serial communication ( by encoding it as high and low to send data to other devices) skills
But the world also has a lot of other things than just “on” and “off” state. For example, temperature levels, control knobs, etc., they have a continuous range of values between high and low. In these cases, pcDuino provides six analog input ，convert the input voltage into a number from 0 (0 v) to 1023 (5 v) . These analog interface is used to measure the “real world” value is perfect, they also allows you to use pcDuino to connect all of these things.[/vc_column_text][/vc_tab][vc_tab title=”Key code” tab_id=”1393916965678-2-9″][vc_column_text]int sensorValue; variable is a value that you have named and stored. Before using these variables, you have to introduce and clarify them; Here we will illustrate a variable called sensorValue, it belongs to the “int” (integer) type. Do not forget that in each case the variable names are used may not be the same.
sensorValue = analogRead (sensorPin); we use analogRead () function to read the value of the analog interface. analogRead () is only one factor, you want to use analog interface with (“sensorPin”), then it returns a 0 (0 volts) to 1023 (5 volts) values (“sensorValue”).
Delay (sensorValue); Arduino reaction is very fast, it every second can run tens of thousands of lines of code. We want to see when it running ,how can we slow it down, we usually insert delay (delays) to the code. (Delay) are calculated in milliseconds, a second 1000 ms.[/vc_column_text][/vc_tab][vc_tab title=”Results” tab_id=”1393916966841-3-3″][vc_column_text]You will see:
As you will see a different position potentiometer, LED light flashes faster or slower. If the circuit is not working, make sure that your circuit is properly connected, compile and upload the code to the board, or refer to the following troubleshooting tips.
This is likely due to poor contact potentiometer pin lead. This problem can be solved by putting the potentiometer down.
Does not work
Make sure you do not accidentally slide piece connected to the digital interface instead of analog interface because it is the potentiometer resistor element
LED lamp is not on?
LED lights will only work in one direction. Try to take it out and rotate 180 degrees reinsert bread board (do not worry, reinsert do not cause any permanent damage).
Real world application:
Most traditional volume knobs employ a potentinometer.[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]