langsung saja
ini gambar skemaya
dan dibawah ini program ya ,disini RTC ya pakek ds3132 karna ada sensor suhuya
#include <DS3231.h>
//#include <Time.h> //http://www.arduino.cc/playground/Code/Time
//#include <Wire.h>
DS3231 rtc(SDA, SCL);
Time waktu;
int nomer;
int seken;
int angka;
int satuan;
int puluhan;
int ratusan;
int ribuan;
int x;
int dataJam = 43;
int dataMenit = 21 ;
uint8_t dataDetik = 0;
int datasex;
int ha;
int ri;
int lm35;
int lm3;
int lm5;
int rlsa;
//digitalWrite(2,LOW);
void setup()
{
// Serial.begin(9600);
rtc.begin();
// put your setup code here, to run once:
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void delok()
{ //tampilkan hari
Serial.println(rtc.getDOWStr(FORMAT_LONG));
//ambil waktu
waktu = rtc.getTime();
dataJam = waktu.hour;
dataMenit = waktu.min;
datasex = waktu.sec;
dataDetik = waktu.date, DEC;
lm35 = (rtc.getTemp());
// Serial.print(dataJam);
//Serial.print(':');
// Serial.print(dataMenit);
// Serial.print(':');
// Serial.println(dataDetik);
//delay(1000);
}
void pecah()
{ satuan = dataMenit % 10;
puluhan = (dataMenit / 10) % 10;
ratusan = dataJam % 10;
ribuan = (dataJam / 10) % 10;
ha = dataDetik % 10;
ri = (dataDetik / 10) % 10;
lm3 = lm35 % 10;
lm5 = (lm35 / 10) % 10;
}
void SEKEN()
{ digitalWrite(7, HIGH);
//delay(0.01);
digitalWrite(7, LOW);
// delay(0.01);
}
void detakken()
{ digitalWrite(4, HIGH);
// delay(0.5);
digitalWrite(4, LOW);
// delay(0.5);
}
void mlaku()
{ for (seken = 0; seken < 18; seken++)
{ digitalWrite(5, HIGH); //A
// delay(0.011);
digitalWrite(3, HIGH); //A
// delay(0.01);
switch (seken) {
case 0:
angka = lm5;
digitalWrite(2, HIGH);
// delay(0.01);
detakken();
sexmen();
digitalWrite(4, LOW);
// delay(0.01);
break;
case 1:
angka = ribuan;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
break;
case 2:
angka = ratusan;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
break;
case 3:
angka = puluhan;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
break;
case 4:
angka = satuan;
digitalWrite(2, LOW);
//delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
break;
case 5:
angka = ri;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(1);
break;
case 6:
angka = ha;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
break;
case 7:
angka = lm5;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
break;
case 8:
angka = lm3;
digitalWrite(2, LOW);
// delay(0.01);
detakken();
sexmen();
digitalWrite(3, LOW);
delay(2);
digitalWrite(5, LOW);
delay(1);
break;
}
}
}
void sexmen()
{ digitalWrite(8, LOW);
delay(0.001);
switch (angka) {
case 0:
digitalWrite(8, HIGH);
delay(0.01);
digitalWrite(6, HIGH);
SEKEN();
digitalWrite(6, LOW);
SEKEN();
digitalWrite(6, LOW);
SEKEN();
digitalWrite(6, LOW);
SEKEN();
digitalWrite(6, LOW);
SEKEN();
digitalWrite(6, LOW);
SEKEN();
digitalWrite(6, LOW);
SEKEN();
digitalWrite(8, HIGH); //G
SEKEN();
break;
case 1:
digitalWrite(8, HIGH);
delay(0.01);
digitalWrite(6, HIGH); //G
SEKEN();
digitalWrite(6, HIGH); //F
SEKEN();
digitalWrite(6, HIGH); //E
SEKEN();
digitalWrite(6, HIGH); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, HIGH); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 2:
digitalWrite(8, HIGH);
delay(0.01);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, HIGH); //F
SEKEN();
digitalWrite(6, LOW); //E
SEKEN();
digitalWrite(6, LOW); //D
SEKEN();
digitalWrite(6, HIGH); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 3:
digitalWrite(8, HIGH);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, HIGH); //F
SEKEN();
digitalWrite(6, HIGH); //E
SEKEN();
digitalWrite(6, LOW); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 4:
digitalWrite(8, HIGH);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, LOW); //F
SEKEN();
digitalWrite(6, HIGH); //E
SEKEN();
digitalWrite(6, HIGH); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, HIGH); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 5:
digitalWrite(8, HIGH);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, LOW); //F
SEKEN();
digitalWrite(6, HIGH); //E
SEKEN();
digitalWrite(6, LOW); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, HIGH); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 6:
digitalWrite(8, HIGH);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, LOW); //F
SEKEN();
digitalWrite(6, LOW); //E
SEKEN();
digitalWrite(6, LOW); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, HIGH); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 7:
digitalWrite(8, HIGH);
digitalWrite(6, HIGH); //G
SEKEN();
digitalWrite(6, HIGH); //F
SEKEN();
digitalWrite(6, HIGH); //E
SEKEN();
digitalWrite(6, HIGH); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 8:
digitalWrite(8, HIGH);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, LOW); //F
SEKEN();
digitalWrite(6, LOW); //E
SEKEN();
digitalWrite(6, LOW); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
case 9:
digitalWrite(8, HIGH);
digitalWrite(6, LOW); //G
SEKEN();
digitalWrite(6, LOW); //F
SEKEN();
digitalWrite(6, HIGH); //E
SEKEN();
digitalWrite(6, LOW); //D
SEKEN();
digitalWrite(6, LOW); //C
SEKEN();
digitalWrite(6, LOW); //B
SEKEN();
digitalWrite(6, LOW); //A
SEKEN();
digitalWrite(6, HIGH);
SEKEN();
break;
}
}
void bazzer()
{
for (rlsa = 0; rlsa >= 20000; rlsa++)
{
digitalWrite(12, HIGH);
delay(1);
digitalWrite(12, LOW);
delay(1);
}
}
void loop() {
delok();
//analogRead(A0)*0.488;
//pagi
if (dataJam == 06)
{ if (dataMenit == 01)
{ if (datasex == 01)
{ digitalWrite(13, HIGH);
delay(1); bazzer();
digitalWrite(13, LOW);
delay(1);
goto BALBAL;
}
else
{
goto BALBAL;
}
} else
{ goto BALBAL;
}
} BALBAL:
//siang
if (dataJam == 15)
{ if (dataMenit == 10)
{ if (datasex == 05)
{ digitalWrite(13, HIGH);
delay(10);
bazzer();
digitalWrite(13, LOW);
delay(10);
goto BALBALA;
}
else
{
goto BALBALA;
}
} else
{
goto BALBALA;
}
}
BALBALA:
//sore
if (dataJam == 16)
{ if (dataMenit == 49)
{ if (datasex == 01)
{ digitalWrite(9, HIGH);
delay(1);
bazzer();
digitalWrite(9, LOW);
delay(1);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
goto BALBALB;
}
else
{
goto BALBALB;
}
} else
{
goto BALBALB;
}
}
BALBALB:
for (x = 0; x < 20; x++) {
pecah();
mlaku();
}
}//}
nah ini saaat di jalan kan
Senin, 27 Maret 2017
7SEKMEN ARDUINO
NAH DISINI ANE berbagi gimana cara ya arduino jalan kan 7sekmen dengan driver 74ch595
lansung aja kita bahas
ini skema rangkaian di proteus
lansung aja kita bahas
ini skema rangkaian di proteus
nah ini sekarang koding ya di arduino
int nomer=0;
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void SEKEN()
{ digitalWrite(7,HIGH);
delay(1);
digitalWrite(7,LOW);
delay(1);
}
void sexmen()
{ digitalWrite(6,LOW);
delay(0.001);
switch (nomer){
case 0:
digitalWrite(6,HIGH);
delay(1);
digitalWrite(8,HIGH);
SEKEN();
digitalWrite(8,LOW);
SEKEN();
digitalWrite(8,LOW);
SEKEN();
digitalWrite(8,LOW);
SEKEN();
digitalWrite(8,LOW);
SEKEN();
digitalWrite(8,LOW);
SEKEN();
digitalWrite(8,LOW);
SEKEN();
digitalWrite(8,HIGH);//G
SEKEN();
delay(1);
break;
case 1:
digitalWrite(6,HIGH);
delay(1);
digitalWrite(8,HIGH);//G
SEKEN();
digitalWrite(8,HIGH);//F
SEKEN();
digitalWrite(8,HIGH);//E
SEKEN();
digitalWrite(8,HIGH);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,HIGH);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 2:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,HIGH);//F
SEKEN();
digitalWrite(8,LOW);//E
SEKEN();
digitalWrite(8,LOW);//D
SEKEN();
digitalWrite(8,HIGH);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 3:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,HIGH);//F
SEKEN();
digitalWrite(8,HIGH);//E
SEKEN();
digitalWrite(8,LOW);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 4:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,LOW);//F
SEKEN();
digitalWrite(8,HIGH);//E
SEKEN();
digitalWrite(8,HIGH);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,HIGH);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 5:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,LOW);//F
SEKEN();
digitalWrite(8,HIGH);//E
SEKEN();
digitalWrite(8,LOW);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,HIGH);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 6:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,LOW);//F
SEKEN();
digitalWrite(8,LOW);//E
SEKEN();
digitalWrite(8,LOW);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,HIGH);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 7:
digitalWrite(6,HIGH);
digitalWrite(8,HIGH);//G
SEKEN();
digitalWrite(8,HIGH);//F
SEKEN();
digitalWrite(8,HIGH);//E
SEKEN();
digitalWrite(8,HIGH);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 8:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,LOW);//F
SEKEN();
digitalWrite(8,LOW);//E
SEKEN();
digitalWrite(8,LOW);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
case 9:
digitalWrite(6,HIGH);
digitalWrite(8,LOW);//G
SEKEN();
digitalWrite(8,LOW);//F
SEKEN();
digitalWrite(8,HIGH);//E
SEKEN();
digitalWrite(8,LOW);//D
SEKEN();
digitalWrite(8,LOW);//C
SEKEN();
digitalWrite(8,LOW);//B
SEKEN();
digitalWrite(8,LOW);//A
SEKEN();
digitalWrite(8,HIGH);
SEKEN();
delay(1);
break;
}}
void loop()
{
sexmen();
delay(1000);
nomer++;
if(nomer>=10)
{nomer=0;
}
}
udah gituaja jangan bayak bayak wk wk wk
Langganan:
Postingan (Atom)