Tugas Tinkercad LCD 2 Input Sensor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Nama : Deni Ramdani

Nim : 1122523006

Mata kuliah : Mekatronika

Simulasi tinkercad LCD 2 input sensor (suhu dan gas)

Link :

https://www.tinkercad.com/things/0QWAL8Px2Go-tugas-lcd-2-sensor-input-suhugas
Kode Program :

// C++ code

//

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin = A0;

int sensorInput;

double Temp, Lumen;

int gas_pin = A1;

int sensorInput2;

float gas_data = 0;

void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

void loop(){

sensorInput=analogRead(sensorPin);

Temp = (double)sensorInput;
Temp = Temp *1;

Temp = Temp - 0.1;

Temp = Temp *1;

delay (100);

lcd.setCursor(0,0);

lcd.print("Temp");

lcd.setCursor(0,6);

lcd.print(Temp);

int gas_data;

gas_data = analogRead(A1);

lcd.setCursor(9,0);

lcd.print("Gas");

lcd.setCursor(9,1);

lcd.print(gas_data);

delay (100);

}
LCD 2 input sensor (suhu dan ultrasonik)

Link :

https://www.tinkercad.com/things/kZT5hnJWY1D-tugas-lcd-2-sensor-ultrasoniksuhu
Kode Program :

// C++ code

//

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin = A0;

int sensorInput;

double Temp, Lumen;

const int pingPin = A1;

int sensorInput2;

long duration;

int distanceCm, distanceInch;

void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

}
void loop(){

sensorInput=analogRead(sensorPin);

Temp = (double)sensorInput;

Temp = Temp *1;

Temp = Temp - 0.01;

Temp = Temp *1;

delay (20);

lcd.setCursor(0,0);

lcd.print("Temp");

lcd.setCursor(0,6);

lcd.print(Temp);

lcd.setCursor(6,1);

lcd.print("c");

pinMode(pingPin, OUTPUT);

digitalWrite(pingPin, LOW);

delayMicroseconds(2);

digitalWrite(pingPin, HIGH);

delayMicroseconds(5);

pinMode(pingPin, INPUT);

digitalWrite(pingPin, LOW);

duration = pulseIn(pingPin, HIGH);

distanceCm= duration*0.0345/2;

distanceInch = duration*0.0136/2;
lcd.setCursor(8,0);

lcd.print("Cm ");

lcd.print(distanceCm);

delay(10);

lcd.setCursor(8,1);

lcd.print("In ");

lcd.print(distanceInch);

delay(10);

You might also like