langsung aja ya, nah yang kita butuhkan antara lain:
- arduino uno r3
- mini servo
- led
- bluetooth hc06 atau 05
- sterofoam atau gabus atau apa aja yang bisa dibuat rumah rumahan (kalau perlu)
- lcd 2 x16
- potensiometer
- resistor 100 ohm
- protoboard, atau projectboard
- sensor ultrasonic
- jumper seperlunya
- dan sebuah smartphone android
nah kita perlu juga menggunakan library servonya, kalau belum punya bisa ambil disini
penghubungan pinnya sebagai berikut:
LCD ke ARDUINO
VSS = GND
VDD = 5V
V0 = POTENSIO (KAKI
TENGAH POTENSIO)
RS = 12
E = 11
RW = GND
D4 = 5
D5 = 4
D6 = 3
D7 = 2
SENSOR ULTRASONIC KE
ARDUINO
TRIG = 7
ECHO = 6
BUZZER = 8
LED BIRU = A4
LED HIJAU = A3
SERVO = 9
PROGRAM
#define echoPin 6
#define trigPin 7
#define ledbiru A4
#define ledhijau A3
int maximumRange = 200;
// Maximum range needed
int minimumRange = 0; //
Minimum range needed
long duration, distance;
// Duration used to calculate distance
int state = 0;
int flag = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11,
5, 4, 3, 2);
#include <Servo.h>
Servo myservo;
void setup() {
pinMode(8, OUTPUT);
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledbiru, OUTPUT);
pinMode(ledhijau, OUTPUT);
digitalWrite(ledhijau,
LOW);
lcd.begin(16, 2);
myservo.attach(9);
lcd.setCursor(0,1);
lcd.print("--PORTAL TUTUP--");
digitalWrite(ledhijau,LOW);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration/58.2;
Serial.println(distance);
delay(100);
if (distance<=10){
lcd.setCursor(0,0);
lcd.print("----ADA TAMU----");
digitalWrite(ledbiru,HIGH);
}
if (distance<=10){
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(300);
}
else{
digitalWrite(ledbiru,LOW);
digitalWrite(8,LOW);
lcd.setCursor(0,0);
lcd.print("-TIDAK ADA TAMU-");
}
if (Serial.available()
> 0){
state = Serial.read();
flag=0;
}
if (state=='1'){
if (flag ==0){
digitalWrite(ledhijau,HIGH);
lcd.setCursor(0,1);
lcd.print("-PORTAL
TERBUKA-");
myservo.write(180);
delay(3000);
myservo.write(90);
lcd.setCursor(0,1);
lcd.print("--PORTAL
TUTUP--");
digitalWrite(ledhijau,LOW);
flag = 1;
}
}
}
JELASNYA SIMAK LANGSUNG VIDIONYA YA!!!!