김유민gledel
Published

02 Sensor & Display

Bongilcheon High School Fab Lab Academy presents sensor with display.

AdvancedShowcase (no instructions)1 hour962
02 Sensor & Display

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

untitled_sketch_04_Of1ZRQAWix.fzz

Code

Untitled file

Arduino
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int trigPin = 9;
int echoPin = 8;
long distance;
long duration;

void setup() {
  lcd.begin(16, 2);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  ultra();
  lcd.setCursor(0,0);
  lcd.clear();
  lcd.print("UltraSonic");
  lcd.setCursor(0,1);
  lcd.print("distance : ");
  lcd.print(distance);
  lcd.print("cm");
  delay(200);
}

void ultrasonic_distance(){
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance= duration*0.034/2;
}

Credits

김유민
9 projects • 2 followers
" Never do things others can do and will do if there are things others cannot do or will not do. "
gledel
100 projects • 116 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"

Comments