20 LED Knight Rider-2 Using arduino mega

Knight Rider-2 simple project using Arduino Mega and 20 LEd.  This example makes use of 20 LEDs connected to the pins 22 – 41 on the board using 40 Ohm resistors and LED driver IC ULN2003. The code example will make the LEDs blink in a sequence, one by one.

Hardware Requirement

  • Arduino Mega
  • ULN2003 X 3 IC
  • 470 Ohms X 20 Resistors
  • Blue LED X 20

Download Arduino Code



Video Of The project


Arduino Code


/* Knight Rider
* Visit www.twovolt.com for Code , Circuit
* Hardware required>>>>Arduino Mega2560 , 20 LED board

*/

int pinArray[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41};
int count = 0;
int timer = 10;

void setup(){
for (count=0;count<20;count++) {
pinMode(pinArray[count], OUTPUT);
}
}

void loop() {
for (count=0;count<19;count++) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count + 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer*2);
}
for (count=19;count>0;count–) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count – 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer*2);
}
}


Arduino 20 LED Knight Rider using arduino mega

Arduino Knight Rider LED effects project consist of 20 LEDs and Arduino mega, refer circuit diagram for LED connections to Arduino. This example makes use of 20 LEDs connected to the pins 22 – 41 on the board using 40 Ohm resistors and LED driver IC ULN2003. The code example will make the LEDs blink in a sequence, one by one using only digitalWrite(pinNum, HIGH/LOW) and delay(time).

Hardware Requirement

  • Arduino Mega
  • ULN2003 X 3 IC
  • 470 Ohms X 20 Resistors
  • Blue LED X 20 ( SMD 0805 LED)

Download Arduino Code



Video of the Project



Arduino Code


/*
Arduino 20 LEDs Knight Rider
Hardware 20 LED board, Arduino Mega 2560
Circuit diagram, PCB layout and code of the project is
available from our website www.twovolt.com

*/
//
int ledPin1 = 22;
int ledPin2 = 23;
int ledPin3 = 24;
int ledPin4 = 25;
int ledPin5 = 26;
int ledPin6 = 27;
int ledPin7 = 28;
int ledPin8 = 29;
int ledPin9 = 30;
int ledPin10 = 31;
int ledPin11 = 32;
int ledPin12 = 33;
int ledPin13 = 34;
int ledPin14 = 35;
int ledPin15 = 36;
int ledPin16 = 37;
int ledPin17 = 38;
int ledPin18 = 39;
int ledPin19 = 40;
int ledPin20 = 41;

const int delayTime = 25;
void setup ()

{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin8, OUTPUT);
pinMode(ledPin9, OUTPUT);
pinMode(ledPin10, OUTPUT);
pinMode(ledPin11, OUTPUT);
pinMode(ledPin12, OUTPUT);
pinMode(ledPin13, OUTPUT);
pinMode(ledPin14, OUTPUT);
pinMode(ledPin15, OUTPUT);
pinMode(ledPin16, OUTPUT);
pinMode(ledPin17, OUTPUT);
pinMode(ledPin18, OUTPUT);
pinMode(ledPin19, OUTPUT);
pinMode(ledPin20, OUTPUT);

}
void loop() {

digitalWrite(ledPin1,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin1,LOW); // LED OFF

digitalWrite(ledPin2,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin2,LOW); // LED OFF

digitalWrite(ledPin3,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin3,LOW); // LED OFF

digitalWrite(ledPin4,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin4,LOW); // LED OFF

digitalWrite(ledPin5,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin5,LOW); // LED OFF

digitalWrite(ledPin6,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin6,LOW); // LED OFF

digitalWrite(ledPin7,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin7,LOW); // LED OFF

digitalWrite(ledPin8,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin8,LOW); // LED OFF

digitalWrite(ledPin9,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin9,LOW); // LED OFF

digitalWrite(ledPin10,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin10,LOW); // LED OFF

digitalWrite(ledPin11,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin11,LOW); // LED OFF

digitalWrite(ledPin12,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin12,LOW); // LED OFF

digitalWrite(ledPin13,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin13,LOW); // LED OFF

digitalWrite(ledPin14,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin14,LOW); // LED OFF

digitalWrite(ledPin15,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin15,LOW); // LED OFF

digitalWrite(ledPin16,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin16,LOW); // LED OFF

digitalWrite(ledPin17,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin17,LOW); // LED OFF

digitalWrite(ledPin18,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin18,LOW); // LED OFF

digitalWrite(ledPin19,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin19,LOW); // LED OFF

digitalWrite(ledPin20,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin20,LOW); // LED OFF

//turn

digitalWrite(ledPin20,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin20,LOW); // LED OFF

digitalWrite(ledPin19,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin19,LOW); // LED OFF

digitalWrite(ledPin18,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin18,LOW); // LED OFF

digitalWrite(ledPin17,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin17,LOW); // LED OFF

digitalWrite(ledPin16,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin16,LOW); // LED OFF

digitalWrite(ledPin15,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin15,LOW); // LED OFF

digitalWrite(ledPin14,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin14,LOW); // LED OFF

digitalWrite(ledPin13,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin13,LOW); // LED OFF

digitalWrite(ledPin12,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin12,LOW); // LED OFF

digitalWrite(ledPin11,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin11,LOW); // LED OFF

digitalWrite(ledPin10,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin10,LOW); // LED OFF

digitalWrite(ledPin9,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin9,LOW); // LED OFF

digitalWrite(ledPin8,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin8,LOW); // LED OFF

digitalWrite(ledPin7,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin7,LOW); // LED OFF

digitalWrite(ledPin6,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin6,LOW); // LED OFF

digitalWrite(ledPin5,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin5,LOW); // LED OFF

digitalWrite(ledPin4,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin4,LOW); // LED OFF

digitalWrite(ledPin3,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin3,LOW); // LED OFF

digitalWrite(ledPin2,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin2,LOW); // LED OFF

digitalWrite(ledPin1,HIGH); // LED ON
delay(delayTime);
digitalWrite(ledPin1,LOW); // LED OFF

}

Arduino Based Digital Voltmeter Using 16X2 LCD (Voltage Range 0 to 5V)

The simple digital voltmeter made  using Arduino  Nano and 16X2 LCD, the project is tested on TWOVOLT Multi-Project LCD Shield; Arduino has a couple of 10 Bit ADC pins, we have used A0 pin as an input. The PR2 Trimmer pot used as input voltage, Remove PR2 to measure the external voltage. 16X2 LCD used to display the measured voltage.  Arduino can be power using USB cable or 12V DC at CN1 VDD and GND pin. PR2 5K Ohms or 10K Ohms can be used.

Arduino Pins LCD

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground

Arduino Pins Vs Devices

  • Switch 1 Arduino Pin A3
  • Switch 2 Arduino Pin D6
  • Switch 3 Arduino Pin D7
  • Current Sensor ACS714 Arduino Pin A5
  • Trimmer Potentiometer Arduino Pin A0
  • LM35 Sensor Arduino Pin A4
  • Power MOSFET Arduino Pin D9
  • Relay Arduino Pin D8

Download Arduino Code


Hardware Required for the Project


Arduino Code for the project


/*
Simple code to mesure the voltage and display on 16X2 LCD, code tested on
Multi project LCD shield from twovolt.com , circuit, pcb layout and code available
at ourwebsite www.twovolt.com and video available at www.youtube.com/thetwovolt
*/
#include “LiquidCrystal.h”

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

float voltage = 0.0;
float temp=0.0;
int analog_value;

void setup()
{
lcd.begin(16, 2);
lcd.setCursor (0,0);
}
void loop()
{

analog_value = analogRead(A0);
voltage = (analog_value * 5.0) / 1024.0;

if (voltage < 0.1)
{
voltage=0.0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Voltage= “);
lcd.print(voltage);
delay(30);
}


Complete Circuit of Arduino Multi-project LCD Shield

Solid State DC Switching using Mosfet-Arduino nano dc-ssr shield

The simple DC switching possible with this MOSFET board, the board is made in form of Arduino Nano shield, the board can be used to drive inductive load as well as resistive load, possible application for the shield are LED dimmer, DC Motor speed controller, DC load ON/OFF, solenoid driver, and lamp dimmer. D2 provided for back EMF protection which helps to use an inductive load like DC motor or solenoid. The directly seats on top of Arduino Nano, Screw terminal provided to connect the load and Dc supply. This N-Channel MOSFET has been produced using a proprietary PowerTrench® technology to deliver low RDS(on) and optimized BVDSS capability to offer superior performance benefit in the application. FDD8876 MOSFET can drive a high current load, MBRS340 diode protects from back EMF.

Components Details

  • R1 and R2 SMD 5% 0805
  • FDD8876 SMD Mosfet
  • D1 and D2 SMD Mosfets
  • C1, C2 SMD Ceramic 1210 Capacitor
  • CN1,CN2 Screw Terminals 

Features

  • Supply 12V DC
  • Load 4Amps Max
  • PWM Duty Cycle 0 to 100%
  • Arduino Nano D3-PWM Pin-Connected to Mosfet

About MBRS340 Diode

The Schottky Rectifier employs the Schottky Barrier principle in a large area metal-to-silicon power diode. The Schottky Rectifier’s state-of-the-art geometry features epitaxial construction with oxide passivation and metal overlay contact. It is ideally suited for low voltage, high-frequency rectification, or as freewheeling and polarity protection diodes in surface mount applications where compact size and weight are critical to the system.
Features

  • Small Compact Surface Mountable Package with J-Bend Leads
  • Rectangular Package for Automated Handling
  • Highly Stable Oxide Passivated Junction
  • Excellent Ability to Withstand Reverse Avalanche Energy Transients
  • Guarding for Stress Protection

Large Size Bar-Graph Voltage Monitor Using Arduino Mega and 20 Segment 3W White LED

Simple 20 LED  Bar-Graph Voltmeter , each LED display 0.25V, this circuit can measure 5V directly or its can measure higher voltage range using resistor divider. 

Example circuit for resistor divider. If choose Z1=10K and Z2-10K it can measure 0-10V.

Turns on a series of LEDs based on the value of an analog voltage input.  This is a simple way to make a bar graph display. Though this graph uses 20 LEDs, you can use any number by changing the LED count and the pins in the array. This method can be used to control any series of digital outputs that depends on an analog input.

The bar graph – a series of LEDs in a line, such as you see on an audio display – is a common hardware display for analog sensors. It’s made up of a series of LEDs in a row, an analog input like a Potentiometer, and a little code in between. You can buy multi-LED bar graph displays fairly cheaply, like this one. This tutorial demonstrates how to control a series of LEDs in a row, but can be applied to any series of digital outputs.

Download Arduino Code

Download PDF Schematic

Watch Video Of This Project



Arduino Code


/*
* 20 LED Bargraph Meter , code, schematic, PCB layout
available at our website www.twovolt.com

*/

// these constants won’t change:
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 20; // the number of LEDs in the bar graph

int ledPins[] = {
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41
}; // an array of pin numbers to which LEDs are attached

void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}

void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);

// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element’s index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}

Dark Sensitive Interactive Light Using 20 Segment Bar-Graph and Arduino

The Project is based on 20 Segment Bar Graph (2X10 LED PCB), Arduino Mega and LDR, The project converts darkness into a number of LEDs, number of LEDs will glow proportional to darkness falls on LDR. The circuit works with 12V DC and draws 4 Amps while all LEDs are ON. Digital pin D22 to D41 of Arduino used to drive LEDs.


Download Arduino Code

Download PDF Schematic

Watch Video Of This Project


 

Arduino Code


/*
* Dark Sensitive interactive LED Light , The project consist 20 segment Bar-graph white LEDs ,
* Driver transistors for LEDs, LDR, Pull Resistor for LDR and arduino mega
* Code writen for arduino mega, Arduino code, schematic, PCB layout
available at our website www.twovolt.com, This also can be used as dark senst

*/

// these constants won’t change:
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 20; // the number of LEDs in the bar graph

int ledPins[] = {
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41
}; // an array of pin numbers to which LEDs are attached

void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}

void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 350, 950, 0, ledCount);

// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element’s index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}

20 LED Bar-Graph Voltmeter Using Arduino Mega

Simple 20 LED Segment Bar-Graph Voltmeter , each LED display 0.25V, this circuit can measure 5V directly or it can measure higher voltage  using resistor divider.  

Turns on a series of blue LEDs based on the value of an analog voltage input.  This is a simple way to make a bar graph display. Though this graph uses 20 LEDs, you can use any number by changing the LED count and the pins in the array. This method can be used to control any series of digital outputs that depends on an analog input.

Potentiometer is connected to Analog pin A0 of Arduino Mega, VCC and GND

LED Connected to digital pin of Arduino Mega  D22, D23, D24, D25, D26, D27, D28, D29, D30, D31, D32, D33, D34, D35, D36, D37, D38, D39, D40, D41

Note : Circuit can measure 5V DC  voltage,  High voltage can be measure using resistor divider.

The bar graph – a series of LEDs in a line, such as you see on an audio display – is a common hardware display for analog sensors. It’s made up of a series of LEDs in a row, an analog input like a Potentiometer, and a little code in between. You can buy multi-LED bar graph displays fairly cheaply, like this one. This tutorial demonstrates how to control a series of LEDs in a row, but can be applied to any series of digital outputs.

Download Arduino Code

Watch Video Of This Project

Arduino Code


/*
* 20 LED Bargraph Meter , Code writen for arduino mega, project consist
20 blue LED, ULN2003 X 3 as LED driver, code, schematic, PCB layout
available at our website www.twovolt.com

*/

// these constants won’t change:
const int analogPin = A0; // the pin that the potentiometer is attached to
const int ledCount = 20; // the number of LEDs in the bar graph

int ledPins[] = {
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41
}; // an array of pin numbers to which LEDs are attached

void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}

void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);

// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element’s index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}

10X3W White LED Knight Rider Effect ( Arduino Uno)

Simple Project provide knight rider effect with help of 10X3W white LEDs and Arduino Uno, LED connected to D2 to D11 pins of Arduino. 

Download Arduino Code

Arduino Pins Vs LED

  • D2>>LED1
  • D3>>LED2
  • D4>>LED3
  • D5>>LED4
  • D6>>LED5
  • D7>>LED6
  • D8>>LED7
  • D9>>LED8
  • D10>>LED9
  • D11>>LED10

Watch  Video of This Project Here  

Arduino Code


/*
Simple code generate knight rider effect using 10 white LEDs,
Code presented  here is a modification of original code from electroschematics Author P-Marian

*/
int del=50; // sets a default delay time
void setup() {
// initialize the digital pins as outputs:
for (int i = 2; i<=11 ; i++) {
pinMode(i, OUTPUT);
} // end of for loop
} // end of setup

void loop() {
for (int i = 2; i<=11; i++) { // blink from LEDs 2 to 11
digitalWrite(i, HIGH);
delay(del);
digitalWrite(i, LOW);
}
for (int i = 11; i>=3; i–) { // blink from LEDs 11 to 3
digitalWrite(i, HIGH);
delay(del);
digitalWrite(i, LOW);
}
}

Arduino Based DC Motor Speed Controller with 16X2 LCD

The DC motor controller has been designed using Multi-purpose LCD Arduino Nano shield, circuit, PCB layout  and Arduino code available at our website www.twovolt.com , it can control DC motor 7-12V DC , it can drive motor upto 5Amps. Speed of motor can be set using trimmer potentiometer, 16X2 LCD display the Bar-Graph of speed of motor. Potentiometer is connected to Analog Pin A0 and Digital pin 9 which provides PWM output, this PWM signal goes to gate of MOSFET.

Compact multipurpose Arduino Nano 16X2 LCD shield can be used to develop various projects, shield provided with various things, LM 35 Temperature sensor, 3X Tactile Switch, Vertical trimmer Potentiometer, 12V Relay with NO/NC output, power Mosfet, AC714 current sensor and 16X2 LCD.

Arduino/LCD Pins

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground

Arduino Pins Various Devices

  • Switch 1 Arduino Pin A3
  • Switch 2 Arduino Pin D6
  • Switch 3 Arduino Pin D7
  • Current Sensor ACS714 Arduino Pin A5
  • Trimmer Potentiometer Arduino Pin A0
  • LM35 Sensor Arduino Pin A4
  • Power Mosfet Arduino Pin D9
  • Relay Arduino Pin D8

Arduino Code


/*
Motor Speed Controller with 16X2 LCD Bar-Graph Display, Circuit, PCB Layout ,
and code available at our website www.twovolt.com, Its Modified code,
original author of the code is Rui Santos, http://randomnerdtutorials.com/

*/

// include the library code
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int potPin = A0; // Potentiometer
int motorPin = 9; // Driver FET PWM
int potValue = 0; // Pot Value
int motorspeed = 0; // Pot Value to PWM
int pBari = 0; // Bar-Graph
int i = 0; // foor loop

//progress bar character
byte pBar[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};

void setup() {
// setup our led as an OUTPUT
pinMode(motorPin, OUTPUT);
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD
lcd.print(” MOTOR SPEED”);
//Create the progress bar character
lcd.createChar(0, pBar);
}

void loop() {
// clears the LCD screen
lcd.clear();
// Print a message to the LCD
lcd.print(” MOTOR SPEED”);
//set the cursor to line number 2
lcd.setCursor(0,1);
// read the value from the potentiometer
potValue = analogRead(potPin);
// turns the potValue into a Speed Of the Motor
motorspeed=map(potValue, 0, 1024, 0, 255);
//Speed up the motor
analogWrite(motorPin, motorspeed);
// turns the brighness into a percentage for the bar
pBari=map(motorspeed, 0, 255, 0, 17);
//prints the progress bar
for (i=0; i<pBari; i++)
{
lcd.setCursor(i, 1);
lcd.write(byte(0));
}
// delays 350 ms
delay(350);
}


Download Arduino Code

LED Dimmer Using Arduino 16X2 LCD and Potentiometer

Another  project LED Dimmer using multi LCD Arduino Nano shield, vertical trimmer potentiometer can used to adjust the LED brightness, LCD shows the bar-graph reading of LED dimmer.  MOSFET helps to drive LED up to 5A constant. Circuit works with 12V DC. Project has many parts , unused parts can be used omit if not required.

Arduino Pins

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • Arduino Analog Pin A0 Potentiometer
  • Arduino Digital PWM D9 LED Driver

Arduino Code


/*
LED Dimmer with 16X2 LCD Bar-Graph Display, Circuit, PCB Layout ,
and code available at our website www.twovolt.com, Modified code,
original author of the code is Rui Santos, http://randomnerdtutorials.com/

*/

// include the library code
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int potPin = A0; // Potentiometer
int ledPin = 9; // Driver FET PWM
int potValue = 0; // Pot Value
int brightness = 0; // Pot Value to PWM
int pBari = 0; // Bar-Graph
int i = 0; // foor loop

//progress bar character for brightness
byte pBar[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};

void setup() {
// setup our led as an OUTPUT
pinMode(ledPin, OUTPUT);
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD
lcd.print(” LED Brightness”);
//Create the progress bar character
lcd.createChar(0, pBar);
}

void loop() {
// clears the LCD screen
lcd.clear();
// Print a message to the LCD
lcd.print(” LED Dimmer”);
//set the cursor to line number 2
lcd.setCursor(0,1);
// read the value from the potentiometer
potValue = analogRead(potPin);
// turns the potValue into a brightness for the LED
brightness=map(potValue, 0, 1024, 0, 255);
//lights up the LED according to the bightness
analogWrite(ledPin, brightness);
// turns the brighness into a percentage for the bar
pBari=map(brightness, 0, 255, 0, 17);
//prints the progress bar
for (i=0; i<pBari; i++)
{
lcd.setCursor(i, 1);
lcd.write(byte(0));
}
// delays 750 ms
delay(750);
}

1 2 3