Advertisement
LeventeDaradici

Digital Clock with DS18B20 thermometer with 1.8 inch 7 Segment Display 18101BS and DS1302 RTC clock

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