Home Project #5
Home Project #5
6263328
10/10/2023
2631
Florida International University
Home Project #5
LCD, Digital and Analog Inputs, Serial Communication
EML 4804 Introduction to Mechatronics
Fall 2023
Introduction:
The purpose for Home Project #5 is to properly demonstrate the use of the 16-pin interface16x2
LCD display and the Arduino coder interface in order to implement practical effects such as lines
of words and phrases as well as a timer and run-on displays, in this case the display is connected
to a tactile switch where pressing it makes the screen display either “SWITCH ON” or
“SWITCH OFF,” as well as having a potentiometer control the resistance to display different
voltages depending on how much the resistance is increased or decreased.
Materials Used:
Arduino Board
LCD Screen
2 x 10k Ohm Potentiometer
Tactile Switch
220 Ohm Resistor
Hook-up Wires
Breadboard
Video Link:
https://youtube.com/shorts/zpd5SPce7Ns?si=-O0u1YOLeXnu6oye
Code:
Roberto Valdes
6263328
10/10/2023
/*
Home Project #3 Arduino and LCD
The circuit:
* 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
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld
*/
//LCD display
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int switch_stat;
int potentiometer_sig;
double voltage;
int buttonState;
//Input switch signal to digital pin and store in switch
switch_stat = digitalRead(buttonState);
if (switch_stat == 1) {
//Print message to the LCD
lcd.setCursor(0, 0);
lcd.print("SWITCH ON ");
Serial.print("switch_stat = ");
Serial.print(switch_stat);
Serial.print(" -> Switch OFF ");
}
else if (switch_stat == 0) {
lcd.setCursor(0, 0);
//Print the number of seconds since reset
lcd.print("Switch OFF");
Serial.print("switch_stat = ");
Serial.print(switch_stat);
Serial.print(" -> Switch OFF ");
}
Conclusions:
The circuit was complex to build because although the LCD was easy to connect to the Arduino,
the second potentiometer and the tactile switch were not connecting to the Arduino and the
program despite having the correct connection and code. The only source of error could be the
incorrect pin was being utilized or the circuit was not connected to them since they require a
connection to operate correctly. It’s important to remember that the digital pins and the analog
pins have different functions and cannot be used for the same functions such as reading voltage
on the display and changing the resistance so more or less current can run through the circuit. If I
could improve the circuit, it would be to correctly connect the pin and the analog to the circuit so
that they would read and do what the circuit was intended to do. The code outputted exactly what
I wanted it to display on the LCD screen, so the circuit was the only component of the project
that had to be optimized.
References:
Liquid Crystal “HelloWorld” Tutorial:
https://docs.arduino.cc/learn/electronics/lcd-displays