bismillahirrahmanirrahim................
halo agan2 yg suka dgn microcontroller ,update lg nihh..
pas jln2 saya ngeliat ada jam digital dgn 7segment,jd pengin ngebuat ........jd saya putuskan buat dgn LCD 16x2 aja...hehehehe..soal nya itu yg lagi ada
stok nya..
oke,kita masuk ke skema nya..
Part List nya:
1.Arduino
2.RTC ds1307
3.SHift Register 595
4.trimpot 10k ohm
5.restan 10k ohm = 3 pcs
6.restan 220 ohm
7.battrey backup 3v
8.LCD 16x2
9.switch = 3 pcs
10.crystal 32.768 khz
klau bahan sdh lengkap ,lsng masuk ke sketch nya:
#include <LiquidCrystal595.h>
#include "Wire.h"
#define DS1307_ADDRESS 0x68
const int LM35 = A0;
byte derajat[8] = {
B01110,
B01010,
B01110,
B00000,
B00000,
B00000,
B00000,
B00000};
LiquidCrystal595 lcd(2, 3, 4);
void setup(){
Wire.begin();
Serial.begin(9600);
lcd.begin(16,2); //inisialisasi lcd 16 baris 2 kolom
}
void loop(){
tulis_TGL();
sensor_suhu();
delay(1000);
}
byte bcdToDec(byte val) {
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
}
void tulis_TGL(){
// Reset the register pointer
Wire.beginTransmission(DS1307_ADDRESS);
byte zero = 0x00;
Wire.write(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
int Detik = bcdToDec(Wire.read());
int Menit = bcdToDec(Wire.read());
int Jam= bcdToDec(Wire.read() & 0b111111); //24 hour time
int Hari = bcdToDec(Wire.read()); //0-6 -> minggu - sabtu
int Tgl = bcdToDec(Wire.read());
int Bulan = bcdToDec(Wire.read());
int Thn = bcdToDec(Wire.read());
lcd.setCursor(0,1);
switch (Hari) // tulis hari
{
case 1:
lcd.print("Sen,");
// Serial.print("Sen ");
break;
case 2:
lcd.print("Sel,");
// Serial.print("Sel ");
break;
case 3:
lcd.print("Rab,");
//Serial.print("Rab ");
break;
case 4:
lcd.print("Kam,");
//Serial.print("Kam ");
break;
case 5:
lcd.print("Jum,");
// Serial.print("Jum ");
break;
case 6:
lcd.print("Sab,");
// Serial.print("SAb ");
break;
case 7:
lcd.print("Min,");
// Serial.print("Min ");
break;
}
Serial.print(Tgl);
Serial.print("/");
Serial.print(Bln);
Serial.print("/");
Serial.print(Thn);
Serial.print(" ");
Serial.print(Jam);
Serial.print(":");
Serial.print(Menit);
Serial.print(":");
Serial.println(Detik);
lcd.setCursor(4,1); //tulis di baris 4 kolom 2
lcd.print(Tgl);
lcd.print("/");
lcd.print(Bln);
lcd.print("/");
lcd.print(Thn);
lcd.setCursor(0,0);
if( Detik == 0)
{
lcd.print(" ");
lcd.setCursor(0,0);
}
lcd.print(Jam);
lcd.print(":");
lcd.print(Menit);
lcd.print(":");
lcd.print(Detik);
}
void sensor_suhu(){
int suhu = analogRead(LM35);
int milivolt = (suhu / 1024.0) * 5000;
int celcius = milivolt / 10;
lcd.setCursor(11,0);
lcd.print(celcius);
lcd.createChar(0,derajat);
lcd.setCursor(13,0);
lcd.write(0);
lcd.print(" C");
}
langsung upload ke board arduino,lsng jadi deh........
ini sdh saya pakai sensor suhu,jd bsa tau kondisi suhu di kamar saya,,
maaf,jika kata2 nya ada yg kurang pas,maklum baru pertama buat blog..
oke sekian dl,kapan 2 saya update lagi ya...
Tidak ada komentar:
Posting Komentar