Project showcase
LCD Backlight and Contrast Control

LCD Backlight and Contrast Control © GPL3+

Control the LCD contrast and background LED with analogWrite!

  • 8,249 views
  • 2 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

I am learning to program the Arduino and making myself some tutorials so I can remember it more easily. I hope it will help you! If a code translation is requested, I'll deliver it. In this project, I want to show how you can control the backlight and contrast of a LCD 16x2 screen.

The only thing you have to do is send PWM Signals to V0 (contrast) and A (backlight) on the LCD pins.

Code

AnalogRead/Write und LCD-SteuerungC/C++
#include <LiquidCrystal.h>

// Integer Bibliothek
int hintergrundLichtPIN = 8;			// Hintergrundlicht PIN
int hintergrundLichtWert = 49;    // Hintergrund Wert = Höher => Heller

int kontrastPIN = 9;							// Kontrast PIN
int kontrastWert = 49;            // Kontrast Wert = Kleiner => mehr Kontrast

int analogWert;

// Setup der LCD Bibliothek
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

  // Computer Schnittstellen-Verbindung
  Serial.begin(9600);
  
  // Setup der PINs
  pinMode(hintergrundLichtPIN, OUTPUT);
  pinMode(kontrastPIN, OUTPUT);
  
  // Kontrast und Hintergrund Steuerung des LCD
  analogWrite(hintergrundLichtPIN, hintergrundLichtWert);
  analogWrite(kontrastPIN, kontrastWert);
  
  // Einführung des LCD in den Microkontroller
  lcd.begin(16, 2);  
  
}

void loop() {

  // Schreiben des AnalogInputs A0
  analogWert = analogRead(A0) / 100;

  // Wertausgabe in die Console(Debugging)
  Serial.print(analogWert);
  Serial.print("\n");             // Neue Zeile
  
  // Sender der Information an den LCD
  lcd.setCursor(0, 0);
  lcd.print("Potentiometer");
  lcd.setCursor(0, 1);
  lcd.print(analogWert);
  lcd.setCursor(2, 1);
	lcd.print("k");
	delay(100);
	
	// Löschung des Feldes(zweite Zeile, zweite Reihe) im LCD
	// Sonst bleibt eine 0 stehen, wenn man auf 10k geht und wieder zurück geht
	lcd.setCursor(1, 1);
	lcd.print(" ");
  delay(7);

}

Schematics

Breadboard
How to connect the PINs together
Lcd kontrast und hintergrund steckplatine yslxoewazh

Comments

Author

Mrkacuklav
zurrealStudios
  • 1 project
  • 1 follower

Additional contributors

  • How to use the lcd-screen by Tom Igoe
  • How to read analog signals by SM
  • How to use pwm signals by SM

Published on

February 15, 2017

Members who respect this project

Doctorcraft773Bulentk

and 4 others

See similar projects
you might like

Similar projects you might like

4 Wire LCD Control with BL and Contrast Using Shift Register

Project showcase by Mike Kowalski

  • 2,123 views
  • 0 comments
  • 11 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,719 views
  • 5 comments
  • 18 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 17,290 views
  • 4 comments
  • 34 respects

Easily Wire a 16x2 LCD

Project showcase by Thomas Kroon

  • 2,016 views
  • 0 comments
  • 9 respects

Using 16x2 LCD with Arduino

by Techmirtz

  • 19,422 views
  • 3 comments
  • 34 respects
Add projectSign up / Login