lab 13 LCD screens
//LCD text with incrementing number
//Include the library code:
#include <LiquidCrystal.h>
//Start the time at 0
int time = 0;
//Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
//Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
//Print a message to the LCD.
lcd.print("ENGR6 Display");
}
void loop()
{
//Move cursor to second line, first position
lcd.setCursor(0,1);
//Print Current Time
lcd.print(time);
//Wait 1 second
delay(1000);
//Increment the time
time++;
}
//Include the library code:
#include <LiquidCrystal.h>
//Start the time at 0
int time = 0;
//Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
//Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
//Print a message to the LCD.
lcd.print("ENGR6 Display");
}
void loop()
{
//Move cursor to second line, first position
lcd.setCursor(0,1);
//Print Current Time
lcd.print(time);
//Wait 1 second
delay(1000);
//Increment the time
time++;
}
//LCD with Progress Bar
//Include the library code:
#include <LiquidCrystal.h>
//Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//Create the progress bar characters
byte p20[8] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
};
byte p40[8] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
};
byte p60[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
};
byte p80[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
};
byte p100[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};
void setup()
{
//Set up the LCDs number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("ENGR6 Display");
//Make progress characters
lcd.createChar(0, p20);
lcd.createChar(1, p40);
lcd.createChar(2, p60);
lcd.createChar(3, p80);
lcd.createChar(4, p100);
}
void loop()
{
//Move cursor to second line
lcd.setCursor(0,1);
//Clear the line each time it reaches the end
//with 16 " " (spaces)
lcd.print(" ");
//Iterate through each character on the second line
for (int i = 0; i<16; i++)
{
//Iterate through each progress value for each character
for (int j=0; j<5; j++)
{
lcd.setCursor(i, 1); //Move the cursor to this location
lcd.write(j); //Update progress bar
delay(100); //Wait
}
}
}
//LCD text with incrementing number
//Include the library code:
#include <LiquidCrystal.h>
#include <Wire.h>
const int temp_address = 73; //1001100 written as decimal number
int c = 0, f = 0;
//Start the time at 0
int time = 0;
//Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup() {
lcd.begin(16,2);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Wire.begin();
}
void loop() {
lcd.setCursor(0,1);
// read the input on analog pin 1:
int sensorValue = analogRead(A1);
// print out the value you read:
Serial.println(sensorValue);
//Send a request
//Start talking to the device at the specified address
Wire.beginTransmission(temp_address);
//Send a bit asking for register zero, the data register
Wire.write(0);
//Complete Transmission
Wire.endTransmission();
//Read the temperature from the device
//Request 1 Byte from the specified address
Wire.requestFrom(temp_address, 1);
//Wait for response
while(Wire.available() == 0);
//Get the temp and read it into a variable
c = Wire.read();
//Do some math to convert the Celsius to Fahrenheit
f = round(c*9.0/5.0 +32.0);
//Send the temperature in degrees C and F to the serial monitor
Serial.print(c);
Serial.print("C ");
Serial.print(f);
Serial.print("F ");
delay(500);
if(sensorValue >= 477 && sensorValue < 719){
lcd.print(f);
lcd.print("f ");
int val = 1;
while (val == 1){
sensorValue = analogRead(A1);
delay(100);
if(sensorValue >= 719 && sensorValue < 1023){
val --;
}
}
}
else if(sensorValue >= 719 && sensorValue <= 1023){
lcd.print(c);
lcd.print("c ");
}
delay(1); // delay in between reads
}

Comments
Post a Comment