Monitor Suhu Non-Contact Penampil 7Segment MLX90614 ARDUINO
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur suhu suatu benda ataupun suhu manusia. alat ini dilengkapi dengan penampil 7segment sehingga lebih mudah dalam membaca nilainya. sensor yang digunakan adalah mlx90614. untuk lebih jelasnya berikut adalah komponen dan programnya.
a. Arduino Uno
c. Rangkaian Driver 7Segment
#include <Wire.h>
#include <Adafruit_MLX90614.h>
byte zero = B00000011;
byte one = B10011111;
byte two = B00100101;
byte three = B00001101;
byte four = B10011001;
byte five = B01001001;
byte six = B01000001;
byte seven = B00011111;
byte eight = B00000001;
byte nine = B00001001;
//menampilkan titik
byte zerox = B00000010;
byte onex = B10011110;
byte twox = B00100100;
byte threex = B00001100;
byte fourx = B10011000;
byte fivex = B01001000;
byte sixx = B01000000;
byte sevenx = B00011110;
byte eightx = B00000000;
byte ninex = B00001000;
int latchPin = 4; //Pin connected to STR(pin 1) of HEF4094
int clockPin = 3; //Pin connected to CLK(pin 3) of HEF4094
int dataPin = 2; //Pin connected to D(pin 2) of HEF4094
int oe = 5; //Pin connected to OE(pin 2) of HEF4094
int temp;
int x = 5;
int y;
int sensorValue;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
float TargetC;
void setup(){
mlx.begin();
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(oe, OUTPUT);
digitalWrite(oe,HIGH);
}
void loop(){
TargetC = mlx.readObjectTempC();
sensorValue = TargetC * 10;
Serial.print(TargetC);
temp = sensorValue;
int ribuan = temp / 1000;
temp = temp % 1000;
int ratusan = temp / 100;
temp = temp % 100;
int puluhan = temp / 10;
int satuan = temp % 10;
switch(ratusan){
case 0:
ratusan = zero;
break;
case 1:
ratusan = one;
break;
case 2:
ratusan = two;
break;
case 3:
ratusan = three;
break;
case 4:
ratusan = four;
break;
case 5:
ratusan = five;
break;
case 6:
ratusan = six;
break;
case 7:
ratusan = seven;
break;
case 8:
ratusan = eight;
break;
case 9:
ratusan = nine;
break;
}
switch(puluhan){
case 0:
puluhan = zerox;
break;
case 1:
puluhan = onex;
break;
case 2:
puluhan = twox;
break;
case 3:
puluhan = threex;
break;
case 4:
puluhan = fourx;
break;
case 5:
puluhan = fivex;
break;
case 6:
puluhan = sixx;
break;
case 7:
puluhan = sevenx;
break;
case 8:
puluhan = eightx;
break;
case 9:
puluhan = ninex;
break;
}
switch(satuan){
case 0:
satuan = zero;
break;
case 1:
satuan = one;
break;
case 2:
satuan = two;
break;
case 3:
satuan = three;
break;
case 4:
satuan = four;
break;
case 5:
satuan = five;
break;
case 6:
satuan = six;
break;
case 7:
satuan = seven;
break;
case 8:
satuan = eight;
break;
case 9:
satuan = nine;
break;
}
digitalWrite(latchPin, HIGH); //Pull latch HIGH to send data
shiftOut(dataPin, clockPin, LSBFIRST, satuan);
shiftOut(dataPin, clockPin, LSBFIRST, puluhan);
shiftOut(dataPin, clockPin, LSBFIRST, ratusan);
digitalWrite(latchPin, LOW); //Pull latch HIGH to send data
delay(1000);
}
e. VIDEO HASILNYA
No comments:
Post a Comment