Advertisement
LeventeDaradici

Hot Glue Stick Display Clock - Arduino

May 16th, 2022 (edited)
1,300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 26.71 KB | None | 0 0
  1. //
  2. // https://www.youtube.com/c/LeventeDaradici/videos
  3. //
  4.  
  5. #include <MyRealTimeClock.h>
  6. MyRealTimeClock myRTC(6, 7, 8);
  7. #include <EEPROM.h>
  8.  
  9. #include <Shifty.h>
  10. Shifty shift;
  11.  
  12. #include <OneWire.h>
  13. #include <DallasTemperature.h>
  14. #define ONE_WIRE_BUS 2
  15. OneWire oneWire(ONE_WIRE_BUS);
  16. DallasTemperature sensors(&oneWire);
  17.  
  18.   int test, PrimaCitireA3, IntarziereANIMATIE, InitialZISAPTAMANA, InitialZIUA, InitialLUNA, InitialAN, InitialMINUT, InitialORA, NewMINUT, NewORA, PrimaCitire, UltimaStareButonPlus, UltimaStareButonSetup, StareButonPlus, StareButonSetup, scene, t1, t2 ,o, m, o1, o2, m1, m2, Pminut, Pora, minut, ora, num, zeci, sute, mii = 0;
  19.   String STRora,STRmin, STRtemp = "";
  20.   String STRt1, STRt2, STRo1, STRo2, STRm1, STRm2 = "";
  21.   float temperatura = 0;
  22.  
  23.   unsigned long TimpORA = 10000;
  24.   unsigned long TimpTEMP = 20000;
  25.   unsigned long currentMillis;
  26.   unsigned long startMillis;  
  27.   bool AfisatTEMP, AfisatORA = false ;
  28.  
  29. void setup()
  30.      {
  31.        IntarziereANIMATIE = EEPROM.read(0);
  32.        if (IntarziereANIMATIE > 15) IntarziereANIMATIE = 0;
  33.        shift.setBitCount(32);
  34.        shift.setPins(11, 12, 9);
  35.  
  36.        for (test = 0; test <= 32 ; test++)
  37.             {
  38.               shift.writeBit(test - 1, LOW);  
  39.               shift.writeBit(test, HIGH);
  40.               delay(500);
  41.             }
  42.  
  43.        //  myRTC.setDS1302Time(00,18, 30, 1 , 10, 05, 2022);
  44.        pinMode(4, INPUT);
  45.        pinMode(5, INPUT);
  46.        scene = 0;
  47.        startMillis = millis();
  48.        NewMINUT = myRTC.minutes;
  49.        NewORA = myRTC.hours;
  50.      }
  51.  
  52. void loop()
  53.      {
  54.      if (scene == 0)
  55.        {    
  56.         currentMillis = millis();
  57.         if (currentMillis - startMillis <= TimpORA)  
  58.             {
  59.               if (AfisatORA == false)
  60.                  {              
  61.                    AfiseazaORA();
  62.                    AfisatORA = true;
  63.                    AfisatTEMP = false;
  64.                  }
  65.             }
  66.         if (currentMillis - startMillis > TimpORA && currentMillis - startMillis <= TimpTEMP)
  67.            {
  68.               if (AfisatTEMP == false)
  69.                  {
  70.                    AfiseazaTEMP();
  71.                    AfisatORA = false;
  72.                    AfisatTEMP = true;
  73.                  }
  74.            }
  75.         if (currentMillis - startMillis > TimpTEMP)
  76.            {
  77.               startMillis = millis();
  78.            }              
  79.              
  80.        }    
  81.    
  82.  
  83.     StareButonSetup = digitalRead(5);
  84.     if (StareButonSetup != UltimaStareButonSetup)
  85.     {
  86.       if (StareButonSetup == HIGH)
  87.       {
  88.         scene = scene + 1;
  89.         if (scene > 3)
  90.            {
  91.               scene = 0;
  92.               InitialAN = myRTC.year;
  93.               InitialLUNA = myRTC.month;
  94.               InitialZIUA = myRTC.dayofmonth;
  95.               InitialZISAPTAMANA = myRTC.dayofweek;
  96.               EEPROM.update(0, IntarziereANIMATIE);
  97.               startMillis = millis();
  98.               myRTC.setDS1302Time(00,NewMINUT, NewORA, InitialZISAPTAMANA , InitialZIUA, InitialLUNA, InitialAN);
  99.               AfiseazaORA();
  100.            }
  101.         if (scene == 1)
  102.            {
  103.             AfiseazaORA();
  104.             StergeCaracterul(4);
  105.             StergeCaracterul(3);
  106.             PrimaCitire = 0;
  107.            }
  108.         if (scene == 2)
  109.            {
  110.             AfiseazaORA();
  111.             StergeCaracterul(2);
  112.             StergeCaracterul(1);
  113.             PrimaCitire = 0;
  114.            }  
  115.         if (scene == 3)
  116.            {
  117.             StergeRapid();
  118.                   if (IntarziereANIMATIE == 0) zero(2);
  119.                   if (IntarziereANIMATIE == 1) unu(2);
  120.                   if (IntarziereANIMATIE == 2) doi(2);
  121.                   if (IntarziereANIMATIE == 3) trei(2);
  122.                   if (IntarziereANIMATIE == 4) patru(2);
  123.                   if (IntarziereANIMATIE == 5) cinci(2);
  124.                   if (IntarziereANIMATIE == 6) sase(2);
  125.                   if (IntarziereANIMATIE == 7) sapte(2);
  126.                   if (IntarziereANIMATIE == 8) opt(2);
  127.                   if (IntarziereANIMATIE == 9) noua(2);  
  128.                   if (IntarziereANIMATIE == 10) { unu(1);  zero(2);}
  129.                   if (IntarziereANIMATIE == 11) { unu(1);  unu(2);}
  130.                   if (IntarziereANIMATIE == 12) { unu(1);  doi(2);}
  131.                   if (IntarziereANIMATIE == 13) { unu(1);  trei(2);}
  132.                   if (IntarziereANIMATIE == 14) { unu(1);  patru(2);}
  133.                   if (IntarziereANIMATIE == 15) { unu(1);  cinci(2);}  
  134.            }                      
  135.         }
  136.     } else { }
  137.     delay(5);
  138.     UltimaStareButonSetup = StareButonSetup;                  
  139.  
  140.     StareButonPlus = digitalRead(4);
  141.     if (StareButonPlus != UltimaStareButonPlus)
  142.     {
  143.       if (StareButonPlus == HIGH)
  144.       {
  145.  
  146.         if (scene == 1)
  147.            {
  148.             if (PrimaCitire == 0)
  149.                {
  150.                   NewORA = myRTC.hours;
  151.                   InitialORA = NewORA;
  152.                   PrimaCitire = 1;
  153.                }
  154.             NewORA = NewORA + 1;
  155.             if (NewORA > 23)
  156.                 {
  157.                   NewORA = 0;
  158.                 }
  159.                 AfiseazaDoarOra(NewORA);
  160.            }
  161.         if (scene == 2)
  162.            {
  163.      if (PrimaCitire == 0)
  164.                {
  165.                   NewMINUT = myRTC.minutes;
  166.                   InitialMINUT = NewMINUT;
  167.                   PrimaCitire = 1;
  168.                }
  169.             NewMINUT = NewMINUT + 1;
  170.             if (NewMINUT > 59)
  171.                 {
  172.                   NewMINUT = 0;
  173.                 }
  174.                 AfiseazaDoarMINUTUL(NewMINUT);
  175.            }    
  176.  
  177.         if (scene == 3)
  178.            {
  179.        if (PrimaCitireA3 < 1)
  180.                {                                            
  181.                   PrimaCitireA3 = 1;
  182.                }
  183.             IntarziereANIMATIE = IntarziereANIMATIE + 1;
  184.             if (NewORA == 0)
  185.                {
  186.                 if (NewMINUT ==0)
  187.                    {
  188.                       NewMINUT = myRTC.minutes;
  189.                       InitialMINUT = NewMINUT;
  190.                       NewORA = myRTC.hours;
  191.                       InitialORA = NewORA;
  192.                    }
  193.                }
  194.             if (IntarziereANIMATIE > 15)
  195.                 {
  196.                   IntarziereANIMATIE = 0;
  197.                 }
  198.                 StergeRapid();
  199.                 if (IntarziereANIMATIE == 0) zero(2);
  200.                 if (IntarziereANIMATIE == 1) unu(2);
  201.                 if (IntarziereANIMATIE == 2) doi(2);
  202.                 if (IntarziereANIMATIE == 3) trei(2);
  203.                 if (IntarziereANIMATIE == 4) patru(2);
  204.                 if (IntarziereANIMATIE == 5) cinci(2);
  205.                 if (IntarziereANIMATIE == 6) sase(2);
  206.                 if (IntarziereANIMATIE == 7) sapte(2);
  207.                 if (IntarziereANIMATIE == 8) opt(2);
  208.                 if (IntarziereANIMATIE == 9) noua(2);  
  209.                 if (IntarziereANIMATIE == 10) { unu(1);  zero(2);}        
  210.                 if (IntarziereANIMATIE == 11) { unu(1);  unu(2);}
  211.                 if (IntarziereANIMATIE == 12) { unu(1);  doi(2);}
  212.                 if (IntarziereANIMATIE == 13) { unu(1);  trei(2);}
  213.                 if (IntarziereANIMATIE == 14) { unu(1);  patru(2);}
  214.                 if (IntarziereANIMATIE == 15) { unu(1);  cinci(2);}                                                                    
  215.            }                  
  216.         }
  217.     } else { }
  218.     delay(5);
  219.     UltimaStareButonPlus = StareButonPlus;    
  220.          
  221.      }
  222.      
  223. void AfiseazaDoarMINUTUL(int aMINUT)
  224.     {
  225.          String STRaMINUT =  String(aMINUT);
  226.          m1 = STRaMINUT.toInt();
  227.          
  228.          int lungimeMIN = STRaMINUT.length();
  229.          if (lungimeMIN < 2)
  230.             {
  231.                STRm1 = "0";
  232.                STRm2 = STRaMINUT.substring(0,1);
  233.             }
  234.           if (lungimeMIN > 1)
  235.                   {
  236.               STRm1 = STRaMINUT.substring(0,1);
  237.               STRm2 = STRaMINUT.substring(1,2);
  238.  
  239.                   }
  240.         m1 = STRm1.toInt();
  241.         m2 = STRm2.toInt();    
  242.         StergeCaracterul(3);              
  243.         if (m1 == 0) zero(3);
  244.         if (m1 == 1) unu(3);
  245.         if (m1 == 2) doi(3);
  246.         if (m1 == 3) trei(3);
  247.         if (m1 == 4) patru(3);
  248.         if (m1 == 5) cinci(3);
  249.         if (m1 == 6) sase(3);
  250.         if (m1 == 7) sapte(3);
  251.         if (m1 == 8) opt(3);
  252.         if (m1 == 9) noua(3);
  253.        
  254.         StergeCaracterul(4);
  255.         if (m2 == 0) zero(4);
  256.         if (m2 == 1) unu(4);
  257.         if (m2 == 2) doi(4);
  258.         if (m2 == 3) trei(4);
  259.         if (m2 == 4) patru(4);
  260.         if (m2 == 5) cinci(4);
  261.         if (m2 == 6) sase(4);
  262.         if (m2 == 7) sapte(4);
  263.         if (m2 == 8) opt(4);
  264.         if (m2 == 9) noua(4);          
  265.     }
  266.    
  267. void AfiseazaDoarOra(int Aora)
  268.      {
  269.          String STRaORA =  String(Aora);
  270.          o1 = STRaORA.toInt();
  271.          
  272.          int lungimeORA = STRaORA.length();
  273.          if (lungimeORA < 2)
  274.             {
  275.                STRo1 = "0";
  276.                STRo2 = STRaORA.substring(0,1);
  277.             }
  278.          if (lungimeORA > 1)
  279.             {
  280.                STRo1 = STRaORA.substring(0,1);
  281.                STRo2 = STRaORA.substring(1,2);
  282.             }
  283.         o1 = STRo1.toInt();
  284.         o2 = STRo2.toInt();  
  285.            
  286.         StergeCaracterul(1);        
  287.         if (o1 == 0) zero(1);
  288.         if (o1 == 1) unu(1);
  289.         if (o1 == 2) doi(1);
  290.        
  291.         StergeCaracterul(2);              
  292.         if (o2 == 0) zero(2);
  293.         if (o2 == 1) unu(2);
  294.         if (o2 == 2) doi(2);
  295.         if (o2 == 3) trei(2);
  296.         if (o2 == 4) patru(2);
  297.         if (o2 == 5) cinci(2);
  298.         if (o2 == 6) sase(2);
  299.         if (o2 == 7) sapte(2);
  300.         if (o2 == 8) opt(2);
  301.         if (o2 == 9) noua(2);                                                                                                                      
  302.      }
  303.  
  304. void AfiseazaORA()
  305.      {
  306.         STRora = "";
  307.         STRmin = "";
  308.         myRTC.updateTime();
  309.         minut = myRTC.minutes;
  310.         ora = myRTC.hours;    
  311.         AfiseazaDoarOra(ora);
  312.         AfiseazaDoarMINUTUL(minut);      
  313.      }
  314. void AfiseazaTEMP()
  315.      {
  316.  
  317.         sensors.requestTemperatures();
  318.         temperatura = sensors.getTempCByIndex(0);
  319.      
  320.         STRtemp = String(temperatura,0);
  321.         int lungimeTEMP = STRtemp.length();  
  322.          if (lungimeTEMP > 1)
  323.             {
  324.               STRt1 = STRtemp.substring(0,1);
  325.               STRt2 = STRtemp.substring(1,2);
  326.             } else
  327.                   {
  328.                     STRt1 = "0";
  329.                     STRt2 = STRtemp.substring(0,1);
  330.                   }
  331.         t1 = STRt1.toInt();
  332.         t2 = STRt2.toInt();
  333.        
  334.         StergeCaracterul(1);                              
  335.         if (t1 == 0) zero(1);
  336.         if (t1 == 1) unu(1);
  337.         if (t1 == 2) doi(1);
  338.         if (t1 == 3) trei(1);
  339.         if (t1 == 4) patru(1);
  340.         if (t1 == 5) cinci(1);
  341.         if (t1 == 6) sase(1);
  342.         if (t1 == 7) sapte(1);
  343.         if (t1 == 8) opt(1);
  344.         if (t2 == 9) noua(1);
  345.  
  346.         StergeCaracterul(2);                
  347.         if (t2 == 0) zero(2);
  348.         if (t2 == 1) unu(2);
  349.         if (t2 == 2) doi(2);
  350.         if (t2 == 3) trei(2);
  351.         if (t2 == 4) patru(2);
  352.         if (t2 == 5) cinci(2);
  353.         if (t2 == 6) sase(2);
  354.         if (t2 == 7) sapte(2);
  355.         if (t2 == 8) opt(2);
  356.         if (t2 == 9) noua(2);                      
  357.         StergeCaracterul(3);
  358.         grade();
  359.         StergeCaracterul(4);
  360.         Celsius();
  361.        
  362.      }
  363.  
  364. void grade()
  365.      {
  366.              shift.writeBit(9, HIGH);
  367.              pauza();
  368.              shift.writeBit(10, HIGH);
  369.              pauza();
  370.              shift.writeBit(14, HIGH);
  371.              pauza();
  372.              shift.writeBit(15, HIGH);
  373.      }
  374.  
  375. void Celsius()
  376.      {
  377.        shift.writeBit(4, HIGH);
  378.        pauza;
  379.        shift.writeBit(5, HIGH);
  380.        pauza;
  381.        shift.writeBit(6, HIGH);
  382.        pauza;
  383.        shift.writeBit(1, HIGH);
  384.        pauza;
  385.      }
  386.  
  387. void StergeRapid()
  388.      {
  389.         int i;
  390.            for (i = 0; i <= 32 ; i++)
  391.                {
  392.                  shift.writeBit(32-i, LOW);
  393.                }
  394.      }
  395. void StergeTotul()
  396.      {
  397.         int i;
  398.            for (i = 0; i <= 32 ; i++)
  399.                {
  400.                  shift.writeBit(32-i, LOW);
  401.                  pauza();
  402.                }
  403.      }
  404.      
  405. void StergeCaracterul(int i)
  406.      {
  407.        int numar;
  408.       if (i == 4)
  409.          {
  410.            for (numar=0; numar<=8 ; numar++)
  411.                {
  412.                  shift.writeBit(numar, LOW);
  413.                  pauza;
  414.                }
  415.          }
  416.       if (i == 3)
  417.          {
  418.            for (numar=9; numar<=16 ; numar++)
  419.                {
  420.                  shift.writeBit(numar, LOW);
  421.                  pauza;
  422.                }
  423.          }
  424.       if (i == 2)
  425.          {
  426.            for (numar=17; numar<=24 ; numar++)
  427.                {
  428.                  shift.writeBit(numar, LOW);
  429.                  pauza;
  430.                }
  431.          }
  432.       if (i == 1)
  433.          {
  434.            for (numar=25; numar<=32 ; numar++)
  435.                {
  436.                  shift.writeBit(numar, LOW);
  437.                  pauza;
  438.                }
  439.          }
  440.      }
  441. void pauza()
  442.      {
  443.         delay(IntarziereANIMATIE *10);
  444.      }
  445.    
  446. void unu(int c)
  447.      {
  448.        if (c == 4)
  449.           {
  450.              shift.writeBit(2, HIGH);
  451.              pauza();
  452.              shift.writeBit(3, HIGH);
  453.           }
  454.        if (c == 3)
  455.           {
  456.              shift.writeBit(10, HIGH);
  457.              pauza();
  458.              shift.writeBit(11, HIGH);
  459.           }
  460.        if (c == 2)
  461.           {
  462.              shift.writeBit(21, HIGH);
  463.              pauza();
  464.              shift.writeBit(22, HIGH);
  465.           }
  466.        if (c == 1)
  467.           {
  468.              shift.writeBit(29, HIGH);
  469.              pauza();
  470.              shift.writeBit(30, HIGH);
  471.           }
  472.      }  
  473.  
  474. void doi(int c)
  475.      {
  476.        if (c == 4)
  477.           {      
  478.              shift.writeBit(1, HIGH);
  479.              pauza();
  480.              shift.writeBit(2, HIGH);
  481.              pauza();
  482.              shift.writeBit(7, HIGH);
  483.              pauza();
  484.              shift.writeBit(5, HIGH);
  485.              pauza();
  486.              shift.writeBit(4, HIGH);
  487.           }
  488.        if (c == 3)
  489.           {      
  490.              shift.writeBit(9, HIGH);
  491.              pauza();
  492.              shift.writeBit(10, HIGH);
  493.              pauza();
  494.              shift.writeBit(15, HIGH);
  495.              pauza();
  496.              shift.writeBit(13, HIGH);
  497.              pauza();
  498.              shift.writeBit(12, HIGH);
  499.           }
  500.        if (c == 2)
  501.           {      
  502.              shift.writeBit(20, HIGH);
  503.              pauza();
  504.              shift.writeBit(21, HIGH);
  505.              pauza();
  506.              shift.writeBit(23, HIGH);
  507.              pauza();
  508.              shift.writeBit(18, HIGH);
  509.              pauza();
  510.              shift.writeBit(17, HIGH);
  511.           }
  512.        if (c == 1)
  513.           {      
  514.              shift.writeBit(28, HIGH);
  515.              pauza();
  516.              shift.writeBit(29, HIGH);
  517.              pauza();
  518.              shift.writeBit(31, HIGH);
  519.              pauza();
  520.              shift.writeBit(26, HIGH);
  521.              pauza();
  522.              shift.writeBit(25, HIGH);
  523.           }
  524.      }
  525. void trei(int c)
  526.      {
  527.         if (c == 4)
  528.            {  
  529.              shift.writeBit(1, HIGH);
  530.              pauza();
  531.              shift.writeBit(2, HIGH);
  532.              pauza();
  533.              shift.writeBit(7, HIGH);
  534.              pauza();
  535.              shift.writeBit(3, HIGH);
  536.              pauza();
  537.              shift.writeBit(4, HIGH);
  538.            }
  539.         if (c == 3)
  540.            {  
  541.              shift.writeBit(9, HIGH);
  542.              pauza();
  543.              shift.writeBit(10, HIGH);
  544.              pauza();
  545.              shift.writeBit(15, HIGH);
  546.              pauza();
  547.              shift.writeBit(11, HIGH);
  548.              pauza();
  549.              shift.writeBit(12, HIGH);
  550.            }
  551.         if (c == 2)
  552.            {  
  553.              shift.writeBit(20, HIGH);
  554.              pauza();
  555.              shift.writeBit(21, HIGH);
  556.              pauza();
  557.              shift.writeBit(23, HIGH);
  558.              pauza();
  559.              shift.writeBit(22, HIGH);
  560.              pauza();
  561.              shift.writeBit(17, HIGH);
  562.            }
  563.         if (c == 1)
  564.            {  
  565.              shift.writeBit(28, HIGH);
  566.              pauza();
  567.              shift.writeBit(29, HIGH);
  568.              pauza();
  569.              shift.writeBit(31, HIGH);
  570.              pauza();
  571.              shift.writeBit(30, HIGH);
  572.              pauza();
  573.              shift.writeBit(25, HIGH);
  574.            }
  575.      }
  576.  
  577. void patru(int c)
  578.      {
  579.         if (c == 4)
  580.            {  
  581.              shift.writeBit(6, HIGH);
  582.              pauza();
  583.              shift.writeBit(7, HIGH);
  584.              pauza();
  585.              shift.writeBit(2, HIGH);
  586.              pauza();
  587.              shift.writeBit(3, HIGH);
  588.            }
  589.         if (c == 3)
  590.            {  
  591.              shift.writeBit(14, HIGH);
  592.              pauza();
  593.              shift.writeBit(15, HIGH);
  594.              pauza();
  595.              shift.writeBit(10, HIGH);
  596.              pauza();
  597.              shift.writeBit(11, HIGH);
  598.            }
  599.         if (c == 2)
  600.            {  
  601.              shift.writeBit(19, HIGH);
  602.              pauza();
  603.              shift.writeBit(23, HIGH);
  604.              pauza();
  605.              shift.writeBit(21, HIGH);
  606.              pauza();
  607.              shift.writeBit(22, HIGH);
  608.            }
  609.         if (c == 1)
  610.            {  
  611.              shift.writeBit(27, HIGH);
  612.              pauza();
  613.              shift.writeBit(31, HIGH);
  614.              pauza();
  615.              shift.writeBit(29, HIGH);
  616.              pauza();
  617.              shift.writeBit(30, HIGH);
  618.            }
  619.      }
  620.  
  621. void cinci(int c)
  622.      {
  623.         if (c == 4)
  624.            {  
  625.              shift.writeBit(1, HIGH);
  626.              pauza();
  627.              shift.writeBit(6, HIGH);
  628.              pauza();
  629.              shift.writeBit(7, HIGH);
  630.              pauza();
  631.              shift.writeBit(3, HIGH);
  632.              pauza();
  633.              shift.writeBit(4, HIGH);
  634.            }
  635.         if (c == 3)
  636.            {  
  637.              shift.writeBit(9, HIGH);
  638.              pauza();
  639.              shift.writeBit(14, HIGH);
  640.              pauza();
  641.              shift.writeBit(15, HIGH);
  642.              pauza();
  643.              shift.writeBit(11, HIGH);
  644.              pauza();
  645.              shift.writeBit(12, HIGH);
  646.            }
  647.         if (c == 2)
  648.            {  
  649.              shift.writeBit(20, HIGH);
  650.              pauza();
  651.              shift.writeBit(19, HIGH);
  652.              pauza();
  653.              shift.writeBit(23, HIGH);
  654.              pauza();
  655.              shift.writeBit(22, HIGH);
  656.              pauza();
  657.              shift.writeBit(17, HIGH);
  658.            }
  659.         if (c == 1)
  660.            {  
  661.              shift.writeBit(28, HIGH);
  662.              pauza();
  663.              shift.writeBit(27, HIGH);
  664.              pauza();
  665.              shift.writeBit(31, HIGH);
  666.              pauza();
  667.              shift.writeBit(30, HIGH);
  668.              pauza();
  669.              shift.writeBit(25, HIGH);
  670.            }
  671.      }
  672.      
  673. void sase(int c)
  674.      {
  675.         if (c == 4)
  676.            {  
  677.              shift.writeBit(1, HIGH);
  678.              pauza();
  679.              shift.writeBit(6, HIGH);
  680.              pauza();
  681.              shift.writeBit(5, HIGH);
  682.              pauza();
  683.              shift.writeBit(4, HIGH);
  684.              pauza();
  685.              shift.writeBit(3, HIGH);
  686.              pauza();
  687.              shift.writeBit(7, HIGH);
  688.            }
  689.         if (c == 3)
  690.            {  
  691.              shift.writeBit(9, HIGH);
  692.              pauza();
  693.              shift.writeBit(14, HIGH);
  694.              pauza();
  695.              shift.writeBit(13, HIGH);
  696.              pauza();
  697.              shift.writeBit(12, HIGH);
  698.              pauza();
  699.              shift.writeBit(11, HIGH);
  700.              pauza();
  701.              shift.writeBit(15, HIGH);
  702.            }
  703.             if (c == 2)
  704.            {  
  705.              shift.writeBit(20, HIGH);
  706.              pauza();
  707.              shift.writeBit(19, HIGH);
  708.              pauza();
  709.              shift.writeBit(18, HIGH);
  710.              pauza();
  711.              shift.writeBit(17, HIGH);
  712.              pauza();
  713.              shift.writeBit(22, HIGH);
  714.              pauza();
  715.              shift.writeBit(23, HIGH);
  716.            }
  717.             if (c == 1)
  718.            {  
  719.              shift.writeBit(28, HIGH);
  720.              pauza();
  721.              shift.writeBit(27, HIGH);
  722.              pauza();
  723.              shift.writeBit(26, HIGH);
  724.              pauza();
  725.              shift.writeBit(25, HIGH);
  726.              pauza();
  727.              shift.writeBit(30, HIGH);
  728.              pauza();
  729.              shift.writeBit(31, HIGH);
  730.            }
  731.      }    
  732.  
  733. void sapte(int c)
  734.      {
  735.         if (c == 4)
  736.            {  
  737.              shift.writeBit(1, HIGH);
  738.              pauza();
  739.              shift.writeBit(2, HIGH);
  740.              pauza();
  741.              shift.writeBit(3, HIGH);
  742.            }
  743.             if (c == 3)
  744.            {  
  745.              shift.writeBit(9, HIGH);
  746.              pauza();
  747.              shift.writeBit(10, HIGH);
  748.              pauza();
  749.              shift.writeBit(11, HIGH);
  750.            }
  751.             if (c == 2)
  752.            {  
  753.              shift.writeBit(20, HIGH);
  754.              pauza();
  755.              shift.writeBit(21, HIGH);
  756.              pauza();
  757.              shift.writeBit(22, HIGH);
  758.            }
  759.             if (c == 1)
  760.            {  
  761.              shift.writeBit(28, HIGH);
  762.              pauza();
  763.              shift.writeBit(29, HIGH);
  764.              pauza();
  765.              shift.writeBit(30, HIGH);
  766.            }
  767.      }    
  768.  
  769. void opt(int c)
  770.      {
  771.         if (c == 4)
  772.            {  
  773.              shift.writeBit(1, HIGH);
  774.              pauza();
  775.              shift.writeBit(2, HIGH);
  776.              pauza();
  777.              shift.writeBit(3, HIGH);
  778.              pauza();
  779.              shift.writeBit(4, HIGH);
  780.              pauza();
  781.              shift.writeBit(5, HIGH);
  782.              pauza();
  783.              shift.writeBit(6, HIGH);
  784.              pauza();
  785.              shift.writeBit(7, HIGH);
  786.            }
  787.         if (c == 3)
  788.            {  
  789.              shift.writeBit(9, HIGH);
  790.              pauza();
  791.              shift.writeBit(10, HIGH);
  792.              pauza();
  793.              shift.writeBit(11, HIGH);
  794.              pauza();
  795.              shift.writeBit(12, HIGH);
  796.              pauza();
  797.              shift.writeBit(13, HIGH);
  798.              pauza();
  799.              shift.writeBit(14, HIGH);
  800.              pauza();
  801.              shift.writeBit(15, HIGH);
  802.            }
  803.         if (c == 2)
  804.            {  
  805.              shift.writeBit(20, HIGH);
  806.              pauza();
  807.              shift.writeBit(21, HIGH);
  808.              pauza();
  809.              shift.writeBit(22, HIGH);
  810.              pauza();
  811.              shift.writeBit(17, HIGH);
  812.              pauza();
  813.              shift.writeBit(18, HIGH);
  814.              pauza();
  815.              shift.writeBit(19, HIGH);
  816.              pauza();
  817.              shift.writeBit(23, HIGH);
  818.            }
  819.         if (c == 1)
  820.            {  
  821.              shift.writeBit(28, HIGH);
  822.              pauza();
  823.              shift.writeBit(29, HIGH);
  824.              pauza();
  825.              shift.writeBit(30, HIGH);
  826.              pauza();
  827.              shift.writeBit(25, HIGH);
  828.              pauza();
  829.              shift.writeBit(26, HIGH);
  830.              pauza();
  831.              shift.writeBit(27, HIGH);
  832.              pauza();
  833.              shift.writeBit(31, HIGH);
  834.            }
  835.      }        
  836.  
  837. void noua(int c)
  838.      {
  839.         if (c == 4)
  840.            {
  841.              shift.writeBit(7, HIGH);
  842.              pauza();
  843.              shift.writeBit(6, HIGH);
  844.              pauza();
  845.              shift.writeBit(1, HIGH);
  846.              pauza();
  847.              shift.writeBit(2, HIGH);
  848.              pauza();
  849.              shift.writeBit(3, HIGH);
  850.              pauza();
  851.              shift.writeBit(4, HIGH);
  852.            }
  853.         if (c == 3)
  854.            {
  855.              shift.writeBit(15, HIGH);
  856.              pauza();
  857.              shift.writeBit(14, HIGH);
  858.              pauza();
  859.              shift.writeBit(9, HIGH);
  860.              pauza();
  861.              shift.writeBit(10, HIGH);
  862.              pauza();
  863.              shift.writeBit(11, HIGH);
  864.              pauza();
  865.              shift.writeBit(12, HIGH);
  866.            }
  867.         if (c == 2)
  868.            {
  869.              shift.writeBit(23, HIGH);
  870.              pauza();
  871.              shift.writeBit(19, HIGH);
  872.              pauza();
  873.              shift.writeBit(20, HIGH);
  874.              pauza();
  875.              shift.writeBit(21, HIGH);
  876.              pauza();
  877.              shift.writeBit(22, HIGH);
  878.              pauza();
  879.              shift.writeBit(17, HIGH);
  880.            }
  881.         if (c == 1)
  882.            {
  883.              shift.writeBit(31, HIGH);
  884.              pauza();
  885.              shift.writeBit(27, HIGH);
  886.              pauza();
  887.              shift.writeBit(28, HIGH);
  888.              pauza();
  889.              shift.writeBit(29, HIGH);
  890.              pauza();
  891.              shift.writeBit(30, HIGH);
  892.              pauza();
  893.              shift.writeBit(25, HIGH);
  894.            }
  895.      }  
  896.  
  897. void zero(int c)
  898.      {
  899.         if (c == 4)
  900.            {
  901.              shift.writeBit(1, HIGH);
  902.              pauza();
  903.              shift.writeBit(2, HIGH);
  904.              pauza();
  905.              shift.writeBit(3, HIGH);
  906.              pauza();
  907.              shift.writeBit(4, HIGH);
  908.              pauza();
  909.              shift.writeBit(5, HIGH);
  910.              pauza();
  911.              shift.writeBit(6, HIGH);
  912.            }
  913.         if (c == 3)
  914.            {
  915.              shift.writeBit(9, HIGH);
  916.              pauza();
  917.              shift.writeBit(10, HIGH);
  918.              pauza();
  919.              shift.writeBit(11, HIGH);
  920.              pauza();
  921.              shift.writeBit(12, HIGH);
  922.              pauza();
  923.              shift.writeBit(13, HIGH);
  924.              pauza();
  925.              shift.writeBit(14, HIGH);
  926.            }
  927.         if (c == 2)
  928.            {
  929.              shift.writeBit(20, HIGH);
  930.              pauza();
  931.              shift.writeBit(21, HIGH);
  932.              pauza();
  933.              shift.writeBit(22, HIGH);
  934.              pauza();
  935.              shift.writeBit(17, HIGH);
  936.              pauza();
  937.              shift.writeBit(18, HIGH);
  938.              pauza();
  939.              shift.writeBit(19, HIGH);
  940.            }
  941.         if (c == 1)
  942.            {
  943.              shift.writeBit(28, HIGH);
  944.              pauza();
  945.              shift.writeBit(29, HIGH);
  946.              pauza();
  947.              shift.writeBit(30, HIGH);
  948.              pauza();
  949.              shift.writeBit(25, HIGH);
  950.              pauza();
  951.              shift.writeBit(26, HIGH);
  952.              pauza();
  953.              shift.writeBit(27, HIGH);
  954.            }
  955.      }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement