You need to enable javaScript to run this app.

ARDUINO PROGRAM TINGGI BADAN

  • Senin, 18 November 2024
  • Administrator
  • 0 komentar

Komponen:

  1. Mikrokontroler Arduinio R3 x1
  2. 2. LCD I2C 16x2 x1
  3. 3. Senros Ultrasonik (HC-SR04) x1
  4. 4. Kabel Jumper

DIAGRAM WIRING :

//SMK SANJAYA BAJAWA https://www.youtube.com/channel/UCMKSBUFsR4_4c6hWS9902Qw?sub_confirmation=1

library : i2c

#include <LiquidCrystal_I2C.h> // library untuk LCD I2C https://drive.google.com/file/d/1oRZJdgurMirP3-qyCyZwMdTn-ABZBRN7/view?usp=drive_link
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int trigpin = 8;
const int echopin = 9;

long durasi;
int jarak;

 

void setup() {
Serial.begin(9600);
lcd.begin();
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);

}

void loop() {
digitalWrite(trigpin, LOW);
delayMicroseconds(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);

durasi = pulseIn(echopin, HIGH);
jarak = durasi * 0.037 / 2;

int tinggibadan = 200 - jarak;

Serial.print(tinggibadan);
Serial.println(" cm");

lcd.setCursor(0, 0);
lcd.print("Tinggi :");
lcd.setCursor(9, 0);
lcd.print(tinggibadan);
lcd.setCursor(11, 0);
lcd.print("cm");
delay(2000);
lcd.clear();
}


 

Bagikan artikel ini:

Beri Komentar

Jajak Pendapat

PELAJARAN ELEKTRONIKA YANG PALING ANDA SUKAI ADALAH ?

Hasil
Banner