0% found this document useful (0 votes)
11 views10 pages

Home Project #5

Uploaded by

rvald124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views10 pages

Home Project #5

Uploaded by

rvald124
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Roberto Valdes

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

Pictures: (Next Page)


Roberto Valdes
6263328
10/10/2023
Roberto Valdes
6263328
10/10/2023
Roberto Valdes
6263328
10/10/2023
Roberto Valdes
6263328
10/10/2023

Video Link:
https://youtube.com/shorts/zpd5SPce7Ns?si=-O0u1YOLeXnu6oye

Diagrams: (Next Page)


Roberto Valdes
6263328
10/10/2023

Code:
Roberto Valdes
6263328
10/10/2023
/*
Home Project #3 Arduino and LCD

Demonstrates the use a 16x2 LCD display. The LiquidCrystal


library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch prints "Roberto Valdes" to the 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)

Library originally added 18 Apr 2008


by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld

*/

// include the library code:


#include <LiquidCrystal.h>
Roberto Valdes
6263328
10/10/2023
#include <math.h>

//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 ");
}

//Input potentiometer signal to analog pin and store in potentiometer_sig


potentiometer_sig = analogRead(A5);
//Convert signal to voltage reading
voltage = (5./1023.) * potentiometer_sig;
lcd.setCursor(0, 1);
//Print the number of seconds since reset
lcd.print("Voltage = ");
Roberto Valdes
6263328
10/10/2023
lcd.print(voltage);
lcd.print("V");
Serial.print("Voltage (V) = ");
Serial.println(voltage);
delay(250);
}

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

Display Potentiometer Readings on LCD Display


https://techzeero.com/arduino-tutorials/display-potentiometer-readings-on-lcd-display/

Arduino Liquid Crystal Print


https://www.arduino.cc/en/Reference/LiquidCrystalPrint

Arduino Liquid Crystal


https://www.arduino.cc/en/Reference/LiquidCrystal
Roberto Valdes
6263328
10/10/2023

Arduino Digital Inputs


https://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs/arduino-code

Arduino Analog Functions


https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/

Arduino Serial Print Function


https://qxf2.com/blog/arduino-tutorials-for-testers-serial-monitor/

You might also like