CODE
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int triggerPin = 13;
int echoPin = 12;
long duration,distCM,temp_distCM=0;
void setup()
{
lcd.begin();
lcd.setCursor(0,0);
lcd.print("Dist = cm");
pinMode(triggerPin,OUTPUT);
pinMode(echoPin,INPUT);
}
void loop()
{
digitalWrite(triggerPin,LOW);
delayMicroseconds(2);
digitalWrite(triggerPin,HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin,LOW);
duration = pulseIn(echoPin,HIGH);
distCM = duration/58;
if (temp_distCM != distCM)
{
lcd.setCursor(7,0);
lcd.print(" ");
}
lcd.setCursor(7,0);
lcd.print(distCM);
temp_distCM = distCM;
delay(300);
}
รูป
Thursday, September 27, 2018
Subscribe to:
Post Comments (Atom)
สรุปงานที่ 5 Internet of Things (IoT)
Internet of Things (IoT) คืออะไร Internet of Things (IoT) คือ "อินเตอร์เน็ตในทุกสิ่ง" หมายถึง การที่อุปกรณ์ต่างๆ ส...
-
Digital Speedometer and Odometer Circuit using PIC Microcontroller EMBEDDED By Aswinth Raj Jul 27, 2017 24 Digital Speedometer and...
-
How to Save Data using EEPROM in PIC16F877A Microcontroller By Aswinth Raj Aug 10, 2017 2 Saving Data using...
-
Generating PWM using PIC Microcontroller with MPLAB and XC8 EMBEDDED By Aswinth Raj Mar 15, 2017 35 Generating PWM using PIC Micr...
No comments:
Post a Comment