LEDLİ KLASİK SAAT KOD ÇÖZÜMLEME


Standat Proje
Gömülü Yazılım > ARM, PIC, Arduino
Paylaş
Yayın Tarihi
: 30.10.2016
Bitiş Tarihi
: 14.11.2016
Bütçe
: Belirtilmemiş
Proje No
: #1162
Teslim
: Belirtilmemiş
Rapor?
: Hayır

Proje Detayı

ELİMİZDE KODU VE DEVRE ŞEMASI BULUNAN LEDLİ KLASİK SAAT DEVRESİNİN KODLARININ ÇÖZÜMLENİP KARŞISINA AÇIKLAMA ŞEKLİNDE YAZILMASINI İSTİYORUZ.

Soru ve Cevap (4)

  • pic mikroişlemci
    STRIX

    Merhaba tam olarak ne istediğinizi anlayamadım detaylı olarak anlatabilirseniz memnun olurum.

  • pic mikroişlemci
    burctankal

    Kodlar hangi dildedir.

    İşverenin Cevabı:

    ARDUİNO DİLİNDEDİR HOCAM MEVCUT KODDA DEİŞİKLİK YAPILMASI GERKİYOR..

     

  • pic mikroişlemci
    MIDELEKTRONIK

    /*

    These are the switches for turning on 80 LEDS, they are active LOW;

    byte  led1=B11111111;  //(1,11,21,31,41,51,61,71)  

    byte  led2=B11111111;  //(2,12,22,32,42,52,62,72)  

    byte  led3=B11111111;  //(3,13,23,33,43,53,63,73)

    byte  led4=B11111111;  //(4,14,24,34,44,54,64,74)

    byte  led5=B11111111;  //(5,15,25,35,45,55,65,75)

    byte  led6=B11111111;  //(6,16,26,36,46,56,66,76)

    byte  led7=B11111111;  //(7,17,27,37,47,57,67,77)

    byte  led8=B11111111;  //(8,18,28,38,48,58,68,78)

    byte  led9=B11111111;  //(9,19,29,39,49,59,69,79)

    byte led10=B11111111; //(10,20,30,40,50,60,70,80)

    */

     

     

     

    #include "ClickButton.h"

    #include <DS1302.h>

    DS1302 rtc(A3, A4, A5);

    Time t;

     

    byte latchPin = 13; 

    byte clockPin = 12; 

    byte dataPin = 11; 

     

    ClickButton ba(A0, LOW, CLICKBTN_PULLUP);

    ClickButton bb(A1, LOW, CLICKBTN_PULLUP);

    ClickButton bc(A2, LOW, CLICKBTN_PULLUP);

     

    //===GOBALs Starts==================================================

    byte counter=1; // counter for multiplexing switch

    int sInt=1000;

    byte flash=0;

    int plex=10;

    unsigned long t1=0; // timer for multiplexing switch

    unsigned long t2=0;

     

    unsigned long t3=0;

    unsigned long t4=0;

     

    unsigned long t5=0;

    unsigned long t6=0;

     

    boolean setime=0;

    byte secx=0;

    byte minx=0;

    byte hrx=0;

    byte hry=0;

    byte halfday=0;

    byte dayx=0;

     

    byte mode=0;

    boolean dsmode=0;

    boolean showmode=0;

     

    byte LED[11]={255,255,255,255,255,255,255,255,255,255};

    byte dsLED[11]={255,255,255,255,255,255,255,255,255,255};

    byte dsLEDx[11]={0,0,0,0,0,0,0,0,0,0};

    byte shift=B11111111;

    byte love=255;

    byte sbit=255;

    //============================================GOBALs END================

     

    //===SETUPs Start==========================================================================

     

    void setup() {

      

      pinMode(latchPin, OUTPUT);

      pinMode(clockPin, OUTPUT);

      pinMode(dataPin, OUTPUT);

      

     for(byte x=1; x<11; x++){

     pinMode(x, OUTPUT); 

     } 

     

      for(byte x=1; x<11; x++){  //p1-p10-active LOW

    digitalWrite(x,HIGH);

     }     

        

      ba.multiclickTime = 50;

      bb.multiclickTime = 50; 

      bc.multiclickTime = 50; 

     

      ba.debounceTime = 50;

      bb.debounceTime = 50; 

      bc.debounceTime = 50;  

      

     rtc.halt(false);

    t = rtc.getTime();

     dayx=t.dow;

     hry=t.hour;

     minx=t.min;

     secx=t.sec; 

     

    // ds1302 chip hr range: 0-23; min range:0-59; sec range 0-59;

    // convert 24 hr to 12 with am. pm.

        if(hry<12){hrx=hry; halfday=0;}  

        if(hry>=12){hrx=hry-12; halfday=1;}    

      

      

    }  

    //==============================================================SETUPs ENDs====

     

    void loop() {

      

    ba.Update();

    bb.Update(); 

    bc.Update();  

     

    //=======================buttons

     

      if(ba.clicks==1) {mode++;}

      if(ba.clicks==-1) {mode=0;}

      

      if(bb.clicks==-1){secx=0; setime=1;}

      if(bc.clicks==-1){showmode=!showmode;}  

      

      

     //================= update clock every 2 minutes

      if(minx%2==0 && secx==10 && mode==0){

        

        rtc.halt(false);

        t = rtc.getTime();

         dayx=t.dow;

         hry=t.hour;

         minx=t.min;

         secx=t.sec;

         

         

        if(hry<12){hrx=hry; halfday=0;}  

        if(hry>=12){hrx=hry-12; halfday=1;}   

    }    

     

    //=======================clock display

     

    if(dsmode==1){bitWrite(LED[((secx-1)%10)], 7-((secx-1)/10), 1);} 

    if(dsmode==0){bitWrite(dsLEDx[((secx-1)%10)], 7-((secx-1)/10), 0);} 

    if(secx==60){secx=0; minx++; }

    if(minx==60){minx=0; hrx++; }

    if(minx==255){minx=59;}

     

    if(hrx==12){hrx=0;halfday++;}

    if(hrx==255){hrx=11;}

     

    if(halfday==2){halfday=0;dayx++;}

    if(halfday==255){halfday=1;}

    if(dayx==8){dayx=1;}

    if(dayx==0){dayx=7;}

     

    if(showmode==0){  

      sInt=1000;

    //Mode0  -------------------------------------------------------------------------------------------

     

    if(mode==0){

    if(bb.clicks==1) {dsmode=!dsmode;}

    if(bc.clicks==1) {flash++;}

     

    if(dsmode==0){  

    bitWrite(LED[(secx%10)], 7-(secx/10), 0); 

    LED[minx%10]=LED[minx%10] & (bitWrite(shift, (7-(minx/10)), 0)); 

    bitWrite(shift, (7-(minx/10)), 1);

     

    }

     

    if(dsmode==1){

      

    for(byte s=0; s<=minx; s++){

    bitWrite(dsLED[s%10], (7-(s/10)), 0);

    }

     

    if(minx==59){

    for(byte x=0; x<10;x++){

    dsLED[x]=dsLED[x]|B11111100;

    }  

    }

     

    bitWrite(dsLEDx[(secx%10)], 7-(secx/10), 1); 

     

    for(byte s=0; s<10; s++){

    LED[s]=LED[s]&dsLED[s];

    }  

     

    for(byte s=0; s<10; s++){

    LED[s]=LED[s]^dsLEDx[s];

    }  

     

     

    }

     

    LED[hrx%10]=LED[hrx%10] & (bitWrite(shift, (1-(hrx/10)), 0));

    bitWrite(shift, (1-(hrx/10)), 1);

     

    dayF();

     

    if(halfday==0){LED[9]=LED[9]&B11111110;}

    if(halfday==1){LED[9]=LED[9]|B00000001;}

    }

     

    //set min  -------------------------------------------------------------------------------------------

    if(mode==1){

      if(bb.clicks==1) {minx--;}

      if(bc.clicks==1) {minx++;} 

      setime=1; 

      

    LED[minx%10]=LED[minx%10] & (bitWrite(shift, (7-(minx/10)), 0)); 

    bitWrite(shift, (7-(minx/10)), 1);  

    }

     

    //set hr  ------------------------------------------------------

    if(mode==2){

      if(bb.clicks==1) {hrx--;}

      if(bc.clicks==1) {hrx++;}

      setime=1; 

     

    LED[hrx%10]=LED[hrx%10] & (bitWrite(shift, (1-(hrx/10)), 0));

    bitWrite(shift, (1-(hrx/10)), 1); 

     

    }

     

     

     

    //set am/pm  ------------------------------------------------------

    if(mode==3){

      if(bb.clicks==1) {halfday--;}

      if(bc.clicks==1) {halfday++;}

      setime=1; 

      

    if(halfday==0){LED[9]=LED[9]&B11111110;}

    if(halfday==1){LED[9]=LED[9]|B00000001;}  

    }

     

    //set dow  ------------------------------------------------------

    if(mode==4){ 

      if(bb.clicks==1) {dayx--;}

      if(bc.clicks==1) {dayx++;}  

      setime=1; 

      

    dayF();

     

    }

     

    if(mode==5){mode=0;}

    }

     

    //==SHOW MODE=============================================================================================================================

    //LED[hrx%10]=LED[hrx%10] & (bitWrite(shift, (7-(hrx/10)), 0));

     

    if(showmode==1){ 

     sInt=100;  

     

    bitWrite(sbit,(7-love/10), 1);  

    if(love==81){love=0;} 

    LED[love%10]=LED[love%10] & (bitWrite(sbit,(7-love/10), 0));

     

    }

     //==============setime================================================

     if(setime==1){

        

        if(halfday==0){ 

        rtc.halt(false);

        rtc.writeProtect(false);  

        if(hrx<12){ rtc.setTime((hrx), (minx), (secx));}

        if(hrx==12){ rtc.setTime(0, (minx), (secx));}

        rtc.setDOW(dayx); } 

        

        if(halfday==1){ 

        rtc.halt(false);

        rtc.writeProtect(false);      

        if(hrx<12){ rtc.setTime((hrx+12), (minx), (secx)); }

        if(hrx==12){ rtc.setTime(12, (minx), (secx)); }

        rtc.setDOW((dayx)); } 

        

        setime=0;     

      } 

     //==============second timer================================================

      t3=millis(); 

      if (t3-t4>=sInt){

       secx++; 

       love++;

      t4=t3;  

      }

     

     

      t5=millis(); 

      if (t5-t6>=50){  

      for(byte x=0; x<10;x++) {

       LED[x]=255;  

       dsLED[x]=dsLED[x]|B11111111; 

       dsLEDx[x]=dsLEDx[x]&B00000000;}   

      t6=t5;  

      }

     

     

    ///===============multiplexing================================================

    //10

    // 10000

     

    switch (flash){

    case 0:

    plex=10;

    break;

     

    case 1:

    plex=5000;

    break;

     

    case 2:

    plex=10000;

    break;

    }

     

    if(flash==3){flash=0;}

     

     

     

     t1=micros();

      if (t1-t2>=plex){

        

         counter++;

        if(counter==9) counter=1;

     

      if (counter==1){

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }     

     

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B00000001);   

        digitalWrite(latchPin, HIGH);  

     

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 7));

    }

             

      }   

      

      if (counter==2){  

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }      

        

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B00000010);     

        digitalWrite(latchPin, HIGH); 

     

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 6));

      }   

     

      if (counter==3){  

     

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }        

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B00000100);     

        digitalWrite(latchPin, HIGH);    

     

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 5));

      }   

     

      if (counter==4){ 

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }          

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B00001000); 

        digitalWrite(latchPin, HIGH);    

     

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 4));

    }           

      }   

     

      if (counter==5){   

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }          

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B00010000);      

        digitalWrite(latchPin, HIGH);  

     

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 3));

    }      

      }   

     

      if (counter==6){   

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }        

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B00100000); 

        digitalWrite(latchPin, HIGH); 

     

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 2));

    }  

      }   

     

      if (counter==7){

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }        

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B01000000);      

        digitalWrite(latchPin, HIGH);    

        

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 1));

    }

      }   

     

      if (counter==8){  

        

      for(byte x=1; x<11; x++){

    digitalWrite(x,HIGH);

     }        

        digitalWrite(latchPin,LOW); 

        shiftOut(dataPin, clockPin, MSBFIRST ,B10000000);    

        digitalWrite(latchPin, HIGH);  

        

    for(byte x=0;x<10;x++){

        digitalWrite(1+x, bitRead(LED[x], 0));

    }    

      }   

      

     

      t2=t1;

      }

     

    }

     

     

    void dayF () {

     

    switch (dayx){

    case 1:

    LED[2]=LED[2]&B11111110;

    break;

     

    case 2:

    LED[2]=LED[2]&B11111110;

    LED[3]=LED[3]&B11111110;

    break;

     

    case 3:

    LED[2]=LED[2]&B11111110;

    LED[3]=LED[3]&B11111110;

    LED[4]=LED[4]&B11111110;

    break;

     

    case 4:

    LED[2]=LED[2]&B11111110;

    LED[3]=LED[3]&B11111110;

    LED[4]=LED[4]&B11111110;

    LED[5]=LED[5]&B11111110;

    break;

     

    case 5:

    LED[2]=LED[2]&B11111110;

    LED[3]=LED[3]&B11111110;

    LED[4]=LED[4]&B11111110;

    LED[5]=LED[5]&B11111110;

    LED[6]=LED[6]&B11111110;

    break;

     

    case 6:

    LED[2]=LED[2]&B11111110;

    LED[3]=LED[3]&B11111110;

    LED[4]=LED[4]&B11111110;

    LED[5]=LED[5]&B11111110;

    LED[6]=LED[6]&B11111110;

    LED[7]=LED[7]&B11111110;

    break;

     

    case 7:

    LED[2]=LED[2]&B11111110;

    LED[3]=LED[3]&B11111110;

    LED[4]=LED[4]&B11111110;

    LED[5]=LED[5]&B11111110;

    LED[6]=LED[6]&B11111110;

    LED[7]=LED[7]&B11111110;

    LED[8]=LED[8]&B11111110;

    break;

     

    }

    }

     

     

     

  • pic mikroişlemci
    MIDELEKTRONIK

    SAAT GERİ KALIYOR VE ANİMASYONUN BİR TANESİNDE DEĞİŞİKLİK YAPILACAK...


Verilen Teklifler (7)

efes94 (5)
02.11.2016
devrematik (28)
31.10.2016
aladdn16 (3)
31.10.2016
picproje (12)
31.10.2016
stlg (60)
31.10.2016
MERTDEMIR (15)
31.10.2016
ayb (0)
31.10.2016
KAPALI Teklif Verilemez!

Proje Sahibi

MIDELEKTRONIK (4)
53%
Şu an Çevirimdışı
Son işlem 5 saat önce
7 proje girişi
4 işlemli proje
0 iptal edilen
3 süre dolan