Вы находитесь на странице: 1из 3

LAB _8

DHRUVIK BANKER
AU1743034
codes
Q-( 1-a)
#include <LiquidCrystal.h> // to use the liquidcrystal library.
int rs=12;
int en=11;
int DB4=5;
int DB5=4; // declaring variables pins.
int DB6=3;
int DB7=2;
LiquidCrystal lcd(rs, en, DB4, DB5, DB6, DB7); // setting the pins of
lcd. void setup()
{
lcd.begin(16, 2); // beginning lcd setup having 16 columns and 2 rows. }
void loop()
{
lcd.setCursor(0, 0); // setting the cursor.
lcd.print("hello world..."); // for printing in lcd. }
Q-(1-c)
#include <LiquidCrystal.h> // to use the liquidcrystal library.
int rs=12;
int en=11;
int DB4=5; // declaring variables pins. int DB5=4;
int DB6=3;
int DB7=2;
LiquidCrystal lcd(rs, en, DB4, DB5, DB6, DB7); // setting the pins of
lcd. void setup()
{
lcd.begin(16, 2); // beginning lcd setup having 16 columns and 2 rows. }
void loop()
{
lcd.setCursor(2, 0); // setting the cursor.
lcd.print("hello"); // for printing in lcd.
lcd.setCursor(4, 1); // To set cursor at 5 th column and 2 row.
lcd.print("world");
}
Q- (1-d)
#include <LiquidCrystal.h> // to use the liquidcrystal library.
int rs=12;
int en=11;
int DB4=5; // declaring variables pins.
int DB5=4;
int DB6=3;
int DB7=2;
LiquidCrystal lcd(rs, en, DB4, DB5, DB6, DB7); // setting the pins of
lcd. void setup()
{
lcd.begin(16, 2); // beginning lcd setup having 16 columns and 2
rows. }
void loop()
{
lcd.setCursor(0, 0); // setting the cursor.
lcd.print("hello world"); // for printing in lcd. delay(5000); // to wait
for 5 seconds.
lcd.clear(); // to clear the lcd screen.
lcd.setCursor(0, 0); // setting the cursor.
lcd.print("This works:)"); // for printing in lcd. delay(5000);
lcd.clear();
}
Q-(1-e)
#include <LiquidCrystal.h> // to use the liquidcrystal library.
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; // declaring
variables pins.
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // setting the pins of lcd.
void setup()
{
lcd.begin(16, 2); // beginning lcd setup having 16 columns and 2 rows. }
void loop()
{
for(int i=0;i<=27;i++) // for rotating 28 steps. {
lcd.setCursor(13,0); // setting the cursor.
lcd.print("welcome to mechatronics lab"); // for printing in lcd.
lcd.scrollDisplayLeft(); // for moving text from right to left.
delay(500); // to wait for 0.5seconds. }
}
Q- (2-b)
#include <LiquidCrystal.h> // to use the liquidcrystal library.
int rs=12;
int en=11;
int DB4=5; // declaring variables of pin
int DB5=4;
int DB6=3;
int DB7=2;
int sensorpin = A0; // setting sensor pin at pin A0
int pushbutton = 6;
int sensorinput = 7;
LiquidCrystal lcd(rs, en, DB4, DB5, DB6, DB7); // setting the pins of
lcd. void setup()
{
Serial.begin(9600); // Serial startup
lcd.begin(16,2); // lcd Setup. }
void loop()
{
double Value1= digitalRead(pushbutton); // to read the values from
pushbutton
if(value1 == HIGH ) // if the pushbutton is pressed. {
digitalWrite(sensorinput,HIGH);
double value = analogRead(sensorpin); // to read the value of value from
sensor.
// to read and write temperature only when
voltages are given by pushbutton.
double voltage = value/204.6; // to convert the value into the voltage.
double milivoltage = voltage*1000.0; // to get milivoltage . double
temperature =( milivoltage/10.0)-50; // to get the value of temperature.
lcd.print("the temperature :"); // to print the text in lcd screen.
lcd.setCursor(0,1); // to set the cursor.
lcd.print(temperature); // to print the value of temperature in lcd
Screen. delay(2000); // to wait for 2 seconds.
lcd.clear(); // to clear lcd. }
}
Q- (2-a)
#include <LiquidCrystal.h> // to use the liquidcrystal library.
int rs=12;
int en=11;
int DB4=5;
int DB5=4; // declaring the varibles of pins.
int DB6=3;
int DB7=2;
int sensorpin = A0; // setting sensor pin at pin A0
LiquidCrystal lcd(rs, en, DB4, DB5, DB6, DB7); // setting the pins of
lcd.
void setup()
{
Serial.begin(9600); // Serial startup
lcd.begin(16,2); // lcd Setup. }
void loop()
{
double value = analogRead(sensorpin); // to read the value of value from
sensor. double voltage = value/204.6; // to convert the value into the
voltage. double milivoltage = voltage*1000.0; // to get milivoltage .
double temperature =( milivoltage/10.0)-50; // to get the value of
temperature.
Serial.println("the room temperature is"); // to print .
Serial.println(temperature); // to print the temperature
value. delay(2000); // to wait for 2 seconds.
lcd.print("the temperature "); // to print in lcd Screen.
lcd.setCursor(0,1); // to set cursor.
lcd.print(temperature); // to print the value of temperature.
delay(2000);
lcd.clear();
}
Tinkercad link :
https://www.tinkercad.com/things/0X16tp36ga6-
lab8devangau1743035/editel?sharecode=
RGJ760Gef7G3Dv1pcpxzRcBlRHZtXDdLdreezBZHEew=

Вам также может понравиться