Connecting an LCD screen was never this easy before. Connect an LCD (16*2) to Arduino MEGA 2560 without literally using any wires.
You just need the two things, and you have completed this tutorial's requirement.
There is no need to explain much in this tutorial here!!!
you have to do nothing. Just take the LCD screen and connect it as follows.
Just connect VSS to A0 using the image as reference. The other pins will go in naturally.
Congrats! your circuit is complete under 10 seconds!!
(don't worry that the d2 (of lcd)pin did not go inside any header. D3 to D0 are not required actually for this tutorial.)
But yes the main thing that differs here is the code. I will just give you the code, No need to explain it also. Only change the pins in code with few extra addition.
For eg. Here is the original Liquid crystal example to display "hello world":
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
And here is the modified version:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = A3, en = A5, d4 = A9, d5 = A10, d6 = A11, d7 = A12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
pinMode(A14,OUTPUT);
pinMode(A13,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A0,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(A1,OUTPUT);
digitalWrite(A14,LOW);
digitalWrite(A13,HIGH);
digitalWrite(A4,LOW);
digitalWrite(A0,LOW);
digitalWrite(A2,LOW);
digitalWrite(A1,HIGH);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
Likewise, just remove the part of the code to print seconds and "hello world", And now you can use this code as a snippet.
Please follow, share and comment if you liked the project!
Comments