DAFTAR PUSTAKA
[1]
[2] [3]
[4] [5] [6]
[7] [8] [9]
Kadir, Abdul. 2012. Panduan Praktis Mempelajari Aplikasi Mikrokontroler dan Pemrogramannya Menggunakan Arduino. Yogyakarta : Penerbit Andi. Bejo, Agus. 2008. “C&AVR Rahasia Kemudahan Bahasa C dalam Mikrokontroler ATMega8535”. Yogyakarta : Graha Ilmu. Winoto, Ardi. 2008. ”Mikrokontroler AVR ATMega8/32/16/8535 dan Pemrogramannya dengan Bahasa C pada WinAVR”. Bandung : Informatika Bandung. "Getting Started with Arduino". 1 November 2014. http://arduino.cc/en/Guide/HomePage King, Terry."Muxing Around With The CD74HC4067 + Arduino". 29 November 2014. http://bildr.org/2011/02/cd74hc4067arduino/ Boxall, John. "Tutorial – 74HC4067 16-Channel Analog Multiplexer Demultiplexer".29 November 2014.http://tronixstuff.com/2013/08/05/partreview-74hc4067-16-channel-analog-multiplexerdemultiplexer/ King, Terry."LCD-Blue-I2C". 6 Desember 2014. http://arduinoinfo.wikispaces.com/LCD-Blue-I2C "DS1302 Real Time Clock". 13 Desember 2014. http://playground.arduino.cc/Main/DS1302 "Gedung parkir". 25 Januari 2015. http://id.wikipedia.org/wiki/Gedung_parkir
74
LAMPIRAN
/* Dibuat untuk memenuhi syarat wajib kelulusan strata 1 di UMB Author : Agus Faudin No. hp : 085647156889 Email :
[email protected] twitter : agusfaudin tujuan program ini sebagai simulator pemantau lahan parkir digedung bertingkat spesifikasi : Arduino Uno R3 Mux dan Demux : Modul CD4067 Penampil : LCD 20x4 alternatif komunikasi ke penampil : modul pcf8574 Sensor halang : kombinasi infrared dan photodiode serta komparator lm393 RTC : Modul DS1302 Input : push button Ucapan terimakasih ke teman – teman tercinta : Pandi, Dimas, Mora, Qorry, Topan, Vivi, Rini, ©2015 Jakarta, Indonesia */ #include "MUX74HC4067.h" #include
#include <Wire.h> #include
//|
virtuabotixRTC myRTC(6, 7, 8); MUX74HC4067 mux(2, 3, 4, 5); LiquidCrystal_I2C lcd(0x20,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display byte data ; int number=0; const int buttonPin = A3; int ledState = 1; int buttonState = 0; int lastButtonState = 0; long lastDebounceTime = 0; long debounceDelay = 50; const int buttonPin2 = A2; int ledState2 = 1; int buttonState2 = 0; int lastButtonState2 = 0; long lastDebounceTime2 = 0; long debounceDelay2 = 50; int ledState3 = 1; int buttonState3 = 0;
int lastButtonState3 = 0; long lastDebounceTime3 = 0; long debounceDelay3 = 50; int status0=1, status1=1, status2=1, status3=1, status4=1, status5=1, status6=1, status7=1, status8=1; int status9=1, status10=1, status11=1, status12=1, status13=1, status14=1, status15=1, status16=1; unsigned int i,pot, pot1,pot2, pot3,pot4,pot5, pot6,pot7; //Mux control pins int s0 = 10; int s1 = 11; int s2 = 12; int s3 = 13; //Mux in "SIG" pin int signal = 9; byte heart[8] = { 0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000 }; byte armsDown[8] = { 0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b00000, 0b01110, 0b10001 }; byte smiley[8] = { B00000, B01110, B10001, B10001, B10001, B01010, B11011, B00000 }; void setup()
{ lcd.init(); // initialize the lcd lcd.begin(20, 4); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("TUGAS AKHIR"); lcd.setCursor(0, 1); lcd.print("AGUS FAUDIN"); lcd.setCursor(0, 2); lcd.print("NIM :41413110109"); delay(2000); lcd.clear(); lcd.createChar(0, heart); lcd.createChar(1, armsDown); lcd.createChar(2, smiley); mux.signalPin(A0, OUTPUT, DIGITAL); pinMode(s0, OUTPUT); pinMode(s1, OUTPUT); pinMode(s2, OUTPUT); pinMode(s3, OUTPUT); pinMode(signal, INPUT); digitalWrite(s0, LOW); digitalWrite(s1, LOW); digitalWrite(s2, LOW); digitalWrite(s3, LOW); pinMode(buttonPin, INPUT); pinMode(buttonPin2, INPUT); } void potensio(){ pot = analogRead(A1); pot1 = (pot/64)+1; //set kursor jumlah 16 pot2 = (pot/44); //set jam 00-23 jam pot3 = (pot/17.3); //menit, detik jumlah 59 pot4 = (pot/170)+1; //set hari jumlah 7 pot5 = (pot/34)+1; //set tanggal jumlah 31 pot6 = (pot/93)+1; //set bulan jumlah 12 pot7 = (pot/10.3); //set tahun jumlah 99 } void kondisi_demux(){ if(status0==0) {mux.write(0, HIGH); delay(50); if(readMux(0) == HIGH) {mux.write(0, LOW);status0=1;}} if(status1==0) {mux.write(1, HIGH); delay(50); if(readMux(1) == HIGH) {mux.write(1, LOW);status1=1;}} if(status2==0) {mux.write(2, HIGH); delay(50); if(readMux(2) == HIGH) {mux.write(2, LOW);status2=1;}} if(status3==0) {mux.write(3, HIGH); delay(50); if(readMux(3) == HIGH) {mux.write(3, LOW);status3=1;}}
if(status4==0) {mux.write(4, HIGH); delay(50); if(readMux(4) == HIGH) {mux.write(4, LOW);status4=1;}} if(status5==0) {mux.write(5, HIGH); delay(50); if(readMux(5) == HIGH) {mux.write(5, LOW);status5=1;}} if(status6==0) {mux.write(6, HIGH); delay(50); if(readMux(6) == HIGH) {mux.write(6, LOW);status6=1;}} if(status7==0) {mux.write(7, HIGH); delay(50); if(readMux(7) == HIGH) {mux.write(7, LOW);status7=1;}} if(status8==0) {mux.write(8, HIGH); delay(50); if(readMux(8) == HIGH) {mux.write(8, LOW);status8=1;}} if(status9==0) {mux.write(9, HIGH); delay(50); if(readMux(9) == HIGH) {mux.write(9, LOW);status9=1;}} if(status10==0) {mux.write(10, HIGH); delay(50); if(readMux(10) == HIGH) {mux.write(10, LOW);status10=1;}} if(status11==0) {mux.write(11, HIGH); delay(50); if(readMux(11) == HIGH) {mux.write(11, LOW);status11=1;}} if(status12==0) {mux.write(12, HIGH); delay(50); if(readMux(12) == HIGH) {mux.write(12, LOW);status12=1;}} if(status13==0) {mux.write(13, HIGH); delay(50); if(readMux(13) == HIGH) {mux.write(13, LOW);status13=1;}} if(status14==0) {mux.write(14, HIGH); delay(50); if(readMux(14) == HIGH) {mux.write(14, LOW);status14=1;}} if(status15==0) {mux.write(15, HIGH); delay(50); if(readMux(15) == HIGH) {mux.write(15, LOW);status15=1;}} lcd.setCursor(10,0); lcd.print(status0); lcd.setCursor(11,0); lcd.print(status1); lcd.setCursor(12,0); lcd.print(status2); lcd.setCursor(13,0); lcd.print(status3); lcd.setCursor(14,0); lcd.print(status4); lcd.setCursor(15,0); lcd.print(status5); lcd.setCursor(16,0); lcd.print(status6); lcd.setCursor(17,0); lcd.print(status7); } void set_cursor(){ potensio(); switch(pot1){ case 1: lcd.setCursor(0,3);lcd.write(2);lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" ");
lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1A"); break; case 2: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.write(2);lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1B"); break; case 3: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.write(2);lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1C"); break; case 4: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.write(2); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1D"); break; case 5: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.write(2);lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1E"); break; case 6: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" ");
lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.write(2);lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1F"); break; case 7: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.write(2);lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1G"); break; case 8: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.write(2); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("1H"); break; case 9: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.write(2);lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2A"); break; case 10: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.write(2);lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd.setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2B");
break; case 11: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.write(2);lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd .setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2C"); break; case 12: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.write(2); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd .setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2D"); break; case 13: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.write(2);lcd.setCursor(13,3);lcd.print(" ");lcd .setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2E"); break; case 14: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.write(2);lcd .setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2F"); break; case 15: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" ");
lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd .setCursor(14,3);lcd.write(2);lcd.setCursor(15,3);lcd.print(" "); lcd.setCursor(18,1);lcd.print("2G"); break; case 16: lcd.setCursor(0,3);lcd.print(" ");lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(2,3);lcd.print(" ");lcd.setCursor(3,3);lcd.print(" "); lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(5,3);lcd.print(" ");lcd.setCursor(6,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" "); lcd.setCursor(8,3);lcd.print(" ");lcd.setCursor(9,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" ");lcd.setCursor(11,3);lcd.print(" "); lcd.setCursor(12,3);lcd.print(" ");lcd.setCursor(13,3);lcd.print(" ");lcd .setCursor(14,3);lcd.print(" ");lcd.setCursor(15,3);lcd.write(2); lcd.setCursor(18,1);lcd.print("2H"); break; }} void set_day(){ switch(myRTC.dayofweek){ case 1: lcd.setCursor(0,2); lcd.print("Mon"); break; case 2: lcd.setCursor(0,2); lcd.print("Tue"); break; case 3: lcd.setCursor(0,2); lcd.print("Wed"); break; case 4: lcd.setCursor(0,2); lcd.print("Thu"); break; case 5: lcd.setCursor(0,2); lcd.print("Fri"); break; case 6: lcd.setCursor(0,2); lcd.print("Sat"); break; case 7: lcd.setCursor(0,2); lcd.print("Sun"); break; }} void hari(){ switch(myRTC.dayofweek){ case 1: lcd.setCursor(0,1);
lcd.print("Mon"); break; case 2: lcd.setCursor(0,1); lcd.print("Tue"); break; case 3: lcd.setCursor(0,1); lcd.print("Wed"); break; case 4: lcd.setCursor(0,1); lcd.print("Thu"); break; case 5: lcd.setCursor(0,1); lcd.print("Fri"); break; case 6: lcd.setCursor(0,1); lcd.print("Sat"); break; case 7: lcd.setCursor(0,1); lcd.print("Sun"); break; }} void waktu1(){ lcd.setCursor(0,0); lcd.print(myRTC.hours); lcd.setCursor(2,0); lcd.print(":"); lcd.setCursor(3,0); lcd.print(myRTC.minutes); lcd.setCursor(5,0); lcd.print(":"); lcd.setCursor(6,0); lcd.print(myRTC.seconds); if(myRTC.seconds==60) {lcd.setCursor(6,0);lcd.print("0 ");} } void waktu2(){ lcd.setCursor(3,1); lcd.print(","); lcd.setCursor(4,1); lcd.print(myRTC.dayofmonth); lcd.setCursor(6,1); lcd.print("-"); lcd.setCursor(7,1); lcd.print(myRTC.month); lcd.setCursor(9,1); lcd.print("-");
lcd.setCursor(10,1); lcd.print(myRTC.year); } void waktu(){ myRTC.updateTime(); waktu1(); hari(); waktu2(); } void button(){ int reading = digitalRead(buttonPin); // check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise: // If the switch changed, due to noise or pressing: if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so take it as the actual current state: // if the button state has changed: if (reading != buttonState) { buttonState = reading; // only toggle the LED if the new button state is HIGH if (buttonState == HIGH) { if(buttonState == HIGH && pot1==1){ status0 = !status0;} if(buttonState == HIGH && pot1==2){ status1 = !status1;} if(buttonState == HIGH && pot1==3){ status2 = !status2;} if(buttonState == HIGH && pot1==4){ status3 = !status3;} if(buttonState == HIGH && pot1==5){ status4 = !status4;} if(buttonState == HIGH && pot1==6){ status5 = !status5;} if(buttonState == HIGH && pot1==7){ status6 = !status6;} if(buttonState == HIGH && pot1==8){ status7 = !status7;} if(buttonState == HIGH && pot1==9){ status8 = !status8;} if(buttonState == HIGH && pot1==10){ status9 = !status9;} if(buttonState == HIGH && pot1==11){ status10 = !status10;} if(buttonState == HIGH && pot1==12){ status11 = !status11;} if(buttonState == HIGH && pot1==13){ status12 = !status12;} if(buttonState == HIGH && pot1==14){ status13 = !status13;} if(buttonState == HIGH && pot1==15){ status14 = !status14;} if(buttonState == HIGH && pot1==16){ status15 = !status15;} ledState=!ledState; }}} // set the LED: //digitalWrite(ledPin, ledState); //lcd.setCursor(17,0); //lcd.print(ledState);
// save the reading. Next time through the loop, // it'll be the lastButtonState: lastButtonState = reading; } void button2(){ int reading2 = digitalRead(buttonPin2); // check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise: // If the switch changed, due to noise or pressing: if (reading2 != lastButtonState2) { // reset the debouncing timer lastDebounceTime2 = millis(); } if ((millis() - lastDebounceTime2) > debounceDelay2) { // whatever the reading is at, it's been there for longer // than the debounce delay, so take it as the actual current state: // if the button state has changed: if (reading2 != buttonState2) { buttonState2 = reading2; // only toggle the LED if the new button state is HIGH if (buttonState2 == HIGH) { ledState2 = !ledState2; }}} // set the LED: //digitalWrite(ledPin, ledState); //lcd.setCursor(18,0); //lcd.print(ledState2); // save the reading. Next time through the loop, // it'll be the lastButtonState: lastButtonState2 = reading2; } void button3(){ int reading3 = digitalRead(buttonPin); // check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise: // If the switch changed, due to noise or pressing: if (reading3!= lastButtonState3) { // reset the debouncing timer lastDebounceTime3 = millis(); } if ((millis() - lastDebounceTime3) > debounceDelay3) { // whatever the reading is at, it's been there for longer // than the debounce delay, so take it as the actual current state: // if the button state has changed:
if (reading3!= buttonState3) { buttonState3 = reading3; // only toggle the LED if the new button state is HIGH if (buttonState3 == HIGH) { ledState3 = ledState3++; }}} // set the LED: //digitalWrite(ledPin, ledState); lcd.setCursor(18,1); lcd.print(ledState3); lcd.setCursor(13,1); lcd.print(pot); // save the reading. Next time through the loop, // it'll be the lastButtonState: lastButtonState3 = reading3; } void set_waktu1(){ button3(); if(ledState3==8) {ledState3=1;} switch(ledState3){ case 1: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0); lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2); lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print("#");lcd.setCursor(3,1);lcd.print(" ");lcd.setCursor(6,1);lcd.print(" "); lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" "); lcd.setCursor(11,0);lcd.print("Hour "); potensio(); myRTC.hours = pot2; if(myRTC.hours<=9) {lcd.setCursor(1,0);lcd.print(" ");} break; case 2: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0); lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2);
lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print(" ");lcd.setCursor(3,1);lcd.print("#");lcd.setCursor(6,1);lcd.print(" "); lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" "); lcd.setCursor(11,0);lcd.print("Minute"); potensio(); myRTC.minutes = pot3; if(myRTC.minutes<=9) {lcd.setCursor(4,0);lcd.print(" ");} break; case 3: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0); lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2); lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print(" ");lcd.setCursor(3,1);lcd.print(" ");lcd.setCursor(6,1);lcd.print("#"); lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" "); lcd.setCursor(11,0);lcd.print("Second"); potensio(); myRTC.seconds = pot3; if(myRTC.seconds<=9) {lcd.setCursor(7,0);lcd.print(" ");} break; case 4: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0); lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2); lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print(" ");lcd.setCursor(3,1);lcd.print(" ");lcd.setCursor(6,1);lcd.print(" "); lcd.setCursor(1,3);lcd.print("#");lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" "); lcd.setCursor(11,0);lcd.print("Day "); potensio(); myRTC.dayofweek = pot4; break; case 5: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0);
lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2); lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print(" ");lcd.setCursor(3,1);lcd.print(" ");lcd.setCursor(6,1);lcd.print(" "); lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(4,3);lcd.print("#");lcd.setCursor(7,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print(" "); lcd.setCursor(11,0);lcd.print("Date "); potensio(); myRTC.dayofmonth = pot5; if(myRTC.dayofmonth<=9) {lcd.setCursor(5,2);lcd.print(" ");} break; case 6: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0); lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2); lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print(" ");lcd.setCursor(3,1);lcd.print(" ");lcd.setCursor(6,1);lcd.print(" "); lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print("#");lcd.setCursor(10,3);lcd.print(" "); lcd.setCursor(11,0);lcd.print("Month "); potensio(); myRTC.month = pot6; if(myRTC.month<=9) {lcd.setCursor(8,2);lcd.print(" ");} break; case 7: lcd.setCursor(0,0);lcd.print(myRTC.hours);lcd.setCursor(2,0);lcd.print(":");lcd.setCursor( 3,0); lcd.print(myRTC.minutes);lcd.setCursor(5,0);lcd.print(":");lcd.setCursor(6,0);lcd.print(m yRTC.seconds); set_day();lcd.setCursor(3,2);lcd.print(","); lcd.setCursor(4,2); lcd.print(myRTC.dayofmonth);lcd.setCursor(6,2); lcd.print("");lcd.setCursor(7,2);lcd.print(myRTC.month);lcd.setCursor(9,2);lcd.print("");lcd.setCursor(10,2);lcd.print(myRTC.year); lcd.setCursor(0,1);lcd.print(" ");lcd.setCursor(3,1);lcd.print(" ");lcd.setCursor(6,1);lcd.print(" "); lcd.setCursor(1,3);lcd.print(" ");lcd.setCursor(4,3);lcd.print(" ");lcd.setCursor(7,3);lcd.print(" ");lcd.setCursor(10,3);lcd.print("#"); lcd.setCursor(11,0);lcd.print("Year "); potensio(); myRTC.year = pot7+2000; break;
} } void setting(){ lcd.clear(); while(1){ button2(); set_waktu1(); if(ledState2==1) {ledState3=1;lcd.clear();delay(50); lcd.setCursor(0,0); lcd.print("Set Time Save...."); myRTC.setDS1302Time(myRTC.hours, myRTC.minutes, myRTC.seconds, myRTC.dayofweek, myRTC.dayofmonth, myRTC.month, myRTC.year);delay(1000);break; full_program();}} } void full_program(){ for(i = 0; i < 16; i ++){ data = readMux(i); if(data == HIGH){lcd.setCursor(i, 2); lcd.write(0); } else {lcd.setCursor(i, 2);lcd.write(1);} mux.write(i, LOW); potensio(); set_cursor(); waktu(); //delay(500); button(); button2(); if(ledState2==0) {setting();} kondisi_demux(); } } void loop() { full_program(); } int readMux(int channel){ int controlPin[] = {s0, s1, s2, s3}; int muxChannel[16][4]={ {0,0,0,0}, //channel 0 {1,0,0,0}, //channel 1 {0,1,0,0}, //channel 2 {1,1,0,0}, //channel 3 {0,0,1,0}, //channel 4 {1,0,1,0}, //channel 5 {0,1,1,0}, //channel 6 {1,1,1,0}, //channel 7 {0,0,0,1}, //channel 8 {1,0,0,1}, //channel 9 {0,1,0,1}, //channel 10 {1,1,0,1}, //channel 11 {0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13 {0,1,1,1}, //channel 14 {1,1,1,1} //channel 15 }; //loop through the 4 sig for(int i = 0; i < 4; i ++){ digitalWrite(controlPin[i], muxChannel[channel][i]); } //read the value at the SIG pin int val = digitalRead(signal); //return the value return val; }