Tugas Tinkercad LCD 2 Input Sensor
Tugas Tinkercad LCD 2 Input Sensor
Tugas Tinkercad LCD 2 Input Sensor
Nim : 1122523006
Link :
https://www.tinkercad.com/things/0QWAL8Px2Go-tugas-lcd-2-sensor-input-suhugas
Kode Program :
// C++ code
//
#include <LiquidCrystal.h>
int sensorInput;
int sensorInput2;
float gas_data = 0;
void setup() {
lcd.begin(16, 2);
void loop(){
sensorInput=analogRead(sensorPin);
Temp = (double)sensorInput;
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 <LiquidCrystal.h>
int sensorInput;
int sensorInput2;
long duration;
void setup() {
lcd.begin(16, 2);
}
void loop(){
sensorInput=analogRead(sensorPin);
Temp = (double)sensorInput;
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);
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);