The sketch is not as simple as copy and paste both sketches together, I had to modify it to accommodate both devices and to tell the Arduino to get the data from the sensor and display it on the LCD. But the Variables and libraries remain the same.
There is a zipped copy of the sketch in this instructable you can adjust it as you see fit.
I started by defining the libraries we need for the LCD. For more details on how to load the libraries in your Arduino library folder follow the instructions in this instructable:
//load libraries
#include <Wire.h>
#include <LCD.h>
The UART or serial module that is attached to the back of the LCD is responsible for sending and receiving serial communications between the Arduino and the LCD and it has a onboard potentiometer to adjust the brightness of the screen. What you need for this project is: An Arduino UNO; Serial LCD a 16X2; and 4 jumper wires male to female. PIC16F628 based LCD display driver controllable via serial data input and with a 4 button command interface. Picture of the finished display This is a serial data LCD display driver I developed to be used in conjunction with Jeff Keyser’s Wifi router webradio project. This LCD use 8 pins for data display and three pin for control and AL together 16 pin. There will be problem on project if we have to connect numbers of components in single micro-controller to make a compact type of device. To reduce number of pin used in this tutorial we are going to make a serial LCD using data shifting technique. The presented serial LCD module can convert any 16×2 alphanumeric LCD display to a serial LCD which communicates with the main controller using serial communication technique. The brightness of LCD backlight can also be controlled. If the text exceeds 16 characters, the remaining text automatically accommodates in the second line. The circuit simply consists of a PIC micro, ICSP interface, an RS232 level translator and an HD44780 LCD. Serial LCD display Software. The software is contained in two files (note there are many more created by the compiler): 16F877A-serial-lcd.c bit.h. Bit.h contains bit manipulation macros. Project Files.
#include <LiquidCrystal_I2C.h>
The I defined the variables needed by the LCD and the LM35
I added the variable tempf to help display the temperature in Fahrenheit
//Define variables for the LCD
#define I2C_ADDR 0x27 //Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
//define variables for the LM35 temperature sensor
float temp; //Define the temp float variable
float tempf; //Define the Fahrenheit float variable
https://emailpowerup887.weebly.com/sunflower-bean-human-ceremony-zip-mediafire.html. int sensor = 0; // sensor middle pin on analog pin 0
Then I initialized the LCD using this line:
//Initialize the LCD
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
In the Void setup, I tell the Arduinio that I am using a 16X2 LCD, turn on the backlights and print some lines that will not change.
void setup() {
lcd.begin (16,2); //Define the LCD as 16 column by 2 rows
//Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.setCursor(0,0); //goto first column (column 0) and first line (Line 0)
lcd.print('Temp C = '); //Print at cursor Location
Serial Lcd Display Projects
lcd.setCursor(0,1); //goto first column (column 0) and second line (line 1)
lcd.print('Temp F = '); //Print at cursor location
}
In the Void loop I will read the temperature from the sensor, change it to Celsius and display it on the first row, then change it again to Fahrenheit and display it on the second row. The repeat the process every 5 seconds
void loop(){
temp = analogRead(sensor); //assigning the analog output to temp
temp = temp * 0.48828125; //converting volts to degrees celsius ----- 0.48828125 = [(5V*1000)/1024]10 tempf = (temp * 1.8)+32; //Convering from celsius to fahreneit
lcd.setCursor(8,0); //move the cursor to position 8 on row 1
lcd.print(temp); //print the temperature in Celsius
lcd.setCursor(8,1); //move the cursor to position 8 on row 2
lcd.print(tempf); //print the temperature in Fahrenheit
delay(5000); //wait 5 seconds
}
I hope you like it, if you have any questions don't hesitate to ask.
Enjoy
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |