
LED Brightness Regulator
Introduction
In this tutorial you’d be varying the brightness of an LED using a 10k potentiometer and an inventone dev board. This tutorial is pretty easy you should have little or no problem setting it up. All the very best!!!
List of Components
Potentiometer
LED
Resistor
Jumper wires
InventOne dev board
You can get these components from any electronic store around you, or you’d check online from aliexpress, hub360, ebay. To get your inventone board, click here.
Tutorial
A potentiometer basically provides a variable resistance from zero to its maximum possible resistance, in this case we’d be using a 10k potentiometer i.e. it can provide a maximum resistance of 10k ohms.
Inventone has a 10bits ADC whose voltage range is 0V-1V hence, we need a voltage divider to convert the output voltage from the potentiometer to the required range of input voltage for the inventone board.
In this connection, we purposely added two faults just to give you a little something to debug; welcome to the engineering world! when you’ve figured it out you can move on.
So by varying the potentiometer we can vary the output voltage from 0V to about 5V. You might notice that the LED reaches it maximum brightness even before the potentiometer reaches it maximum, this has to do with the problem which we’ve pointed out above so just go on to solve the problem.

Code
Let’s run through the code together. The first two lines defines the pins we’d be using for the Potentiometer and LED. Next we create an integer variable to hold the values we read from the potentiometer.
In the setup, we just establish the nature of the defined pins and begin serial communication with your system. All the loop does is read the voltage level from the potentiometer, print it to the serial monitor and write the same read voltage level to the LED pin.
/*This sketch is used to regulate the brightness of an LED using the InventOne dev. board
Note that the InventOne board is very sensitive with a maximum ADC port voltage of 1V hence use
appropriate voltage division circuit
*/
//Define LED, Potentiometer pins
int Potentiometer = 0;
int LED = 16;
int Value;
void setup() {
pinMode(Potentiometer, INPUT);
pinMode(LED, OUTPUT);
//Begin serial connection
Serial.begin(9600);
}
void loop() {
//Read voltage level from Potentiometer
Value = analogRead(Potentiometer);
Serial.println(Value);
//Write voltage level to LED pin
analogWrite(LED, Value);
delay(20);
}