Advertisement
angga_funkadelic

Motorola GM Remote Channel Steering

Nov 9th, 2014
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 19.18 KB | None | 0 0
  1. /*
  2. ####################################
  3. Motorola GM Remote Channel Steering
  4. by Angga S Arly
  5. anggafunkadelic@gmail.com
  6. www.ngoprekradio.com
  7. 2014
  8. ####################################
  9. */
  10.  
  11. #include <EEPROM.h> // loding librari eeprom
  12. const int BCDPin1 = 4;
  13. const int BCDPin2 = 3;
  14. const int BCDPin3 = 2;
  15. const int BCDPin4 = 1;
  16. const int BCDPinX = 0;
  17. // state BCD dari MT8870
  18. int BCDState1 = 0;
  19. int BCDState2 = 0;
  20. int BCDState3 = 0;
  21. int BCDState4 = 0;
  22. int BCDStateX = 0;
  23. // state hasil decode ke desimal
  24. int S0 = 0;
  25. int S1 = 0;
  26. int S2 = 0;
  27. int S3 = 0;
  28. int S4 = 0;
  29. int S5 = 0;
  30. int S6 = 0;
  31. int S7 = 0;
  32. int S8 = 0;
  33. int S9 = 0;
  34. int SB0 = 0; // bintang
  35. int SP0 = 0; // pager
  36.  
  37. // konci kombinasi
  38. int D1 = 0;
  39. int D2 = 0;
  40. int D3 = 0;
  41. int D4 = 0;
  42. int D5 = 0;
  43. int D6 = 0;
  44. int D7 = 0;
  45.  
  46. int U1 = 0;
  47. int V1 = 0;
  48. int W1 = 0;
  49. int X1 = 0;
  50. int Y1 = 0;
  51. int Z1 = 0;
  52.  
  53.  
  54. // alokasi pin output / relay
  55. const int LedPin1 =  5;
  56. const int LedPin2 =  6;
  57. const int LedPin3 =  7;
  58. const int LedPin4 =  8;
  59. const int LedPin5 =  9;
  60. const int LedPin6 =  10;
  61. const int LedPin7 =  11;
  62. const int LedPin8 =  12;
  63. const int LedPin9 =  13;
  64.  
  65. // loding eeprom
  66. int baca = 0;
  67. int bacaR1 = 0;
  68. int bacaR2 = 0;
  69.  
  70. void setup() {
  71.   //alokasi pin input ( BCD )
  72.   pinMode(BCDPin1, INPUT);  
  73.   pinMode(BCDPin2, INPUT);
  74.   pinMode(BCDPin3, INPUT);
  75.   pinMode(BCDPin4, INPUT);
  76.   pinMode(BCDPinX, INPUT);  
  77.   // alokasi pin output ( Relay )
  78.   pinMode(LedPin1, OUTPUT);
  79.   pinMode(LedPin2, OUTPUT);
  80.   pinMode(LedPin3, OUTPUT);
  81.   pinMode(LedPin4, OUTPUT);
  82.   pinMode(LedPin5, OUTPUT);
  83.   pinMode(LedPin6, OUTPUT);
  84.   pinMode(LedPin7, OUTPUT);
  85.   pinMode(LedPin8, OUTPUT);
  86.   pinMode(LedPin9, OUTPUT);
  87.   bacaeeprom();
  88. }
  89.  
  90. void bacaeeprom() {
  91.   baca = EEPROM.read(100);
  92.   if ( baca == 1 ) {
  93.     ch01();
  94.   }
  95.   if ( baca == 2 ) {
  96.     ch02();
  97.   }
  98.   if ( baca == 3 ) {
  99.     ch03();
  100.   }
  101.   if ( baca == 4 ) {
  102.     ch04();
  103.   }
  104.   if ( baca == 5 ) {
  105.     ch05();
  106.   }
  107.   if ( baca == 6 ) {
  108.     ch06();
  109.   }
  110.   if ( baca == 7 ) {
  111.     ch07();
  112.   }
  113.   if ( baca == 8 ) {
  114.     ch08();
  115.   }
  116.   if ( baca == 9 ) {
  117.     ch09();
  118.   }
  119.   if ( baca == 10 ) {
  120.     ch10();
  121.   }
  122.   if ( baca == 11 ) {
  123.     ch11();
  124.   }
  125.   if ( baca == 12 ) {
  126.     ch12();
  127.   }
  128.   if ( baca == 13 ) {
  129.     ch13();
  130.   }
  131.   if ( baca == 14 ) {
  132.     ch14();
  133.   }
  134.   if ( baca == 15 ) {
  135.     ch15();
  136.   }
  137.   if ( baca == 16 ) {
  138.     ch16();
  139.   }
  140.   if ( baca == 17 ) {
  141.     ch17();
  142.   }
  143.   if ( baca == 18 ) {
  144.     ch18();
  145.   }
  146.   if ( baca == 19 ) {
  147.     ch19();
  148.   }
  149.   if ( baca == 20 ) {
  150.     ch20();
  151.   }
  152.   if ( baca == 21 ) {
  153.     ch21();
  154.   }
  155.   if ( baca == 22 ) {
  156.     ch22();
  157.   }
  158.   if ( baca == 23 ) {
  159.     ch23();
  160.   }
  161.   if ( baca == 24 ) {
  162.     ch24();
  163.   }
  164.   if ( baca == 25 ) {
  165.     ch25();
  166.   }
  167.   if ( baca == 26 ) {
  168.     ch26();
  169.   }
  170.   if ( baca == 27 ) {
  171.     ch27();
  172.   }
  173.   if ( baca == 28 ) {
  174.     ch28();
  175.   }
  176.   if ( baca == 29 ) {
  177.     ch29();
  178.   }
  179.   if ( baca == 30 ) {
  180.     ch30();
  181.   }
  182.   if ( baca == 31 ) {
  183.     ch31();
  184.   }
  185.  
  186.   bacaR1 = EEPROM.read(41);
  187.   bacaR2 = EEPROM.read(51);
  188.   if ( bacaR1 == 1 ) { R1on(); }
  189.   if ( bacaR1 == 0 ) { R1off(); }
  190.   if ( bacaR2 == 1 ) { R2on(); }
  191.   if ( bacaR2 == 0 ) { R2off(); }
  192.  
  193.  
  194. } // END baca eeprom
  195.  
  196.  
  197. void cekinput() {
  198.  
  199.     BCDState1 = digitalRead(BCDPin1);
  200.     BCDState2 = digitalRead(BCDPin2);
  201.     BCDState3 = digitalRead(BCDPin3);
  202.     BCDState4 = digitalRead(BCDPin4);
  203.     BCDStateX = digitalRead(BCDPinX);
  204.  
  205.    
  206.   if (BCDStateX == HIGH) {
  207.         // detek 0    
  208.         if (BCDState1 == LOW) {
  209.           if (BCDState2 == HIGH) {
  210.             if (BCDState3 == LOW) {
  211.               if (BCDState4 == HIGH) {
  212.                 S0 = 1;
  213.                
  214.                
  215.               }
  216.             }
  217.           }
  218.         }
  219.  
  220.         // detek 1
  221.         if (BCDState1 == HIGH) {
  222.           if (BCDState2 == LOW) {
  223.             if (BCDState3 == LOW) {
  224.               if (BCDState4 == LOW) {
  225.                 S1 = 1;
  226.                
  227.               }
  228.             }
  229.           }
  230.         }
  231.        
  232.         // detek 2
  233.         if (BCDState1 == LOW) {
  234.           if (BCDState2 == HIGH) {
  235.             if (BCDState3 == LOW) {
  236.               if (BCDState4 == LOW) {
  237.                 S2 = 1;
  238.                
  239.               }
  240.             }
  241.           }
  242.         }
  243.        
  244.         // detek 3
  245.         if (BCDState1 == HIGH) {
  246.           if (BCDState2 == HIGH) {
  247.             if (BCDState3 == LOW) {
  248.               if (BCDState4 == LOW) {
  249.                 S3 = 1;
  250.                
  251.               }
  252.             }
  253.           }
  254.         }
  255.        
  256.         // detek 4
  257.         if (BCDState1 == LOW) {
  258.           if (BCDState2 == LOW) {
  259.             if (BCDState3 == HIGH) {
  260.               if (BCDState4 == LOW) {
  261.                 S4 = 1;
  262.                
  263.               }
  264.             }
  265.           }
  266.         }
  267.        
  268.         // detek 5
  269.         if (BCDState1 == HIGH) {
  270.           if (BCDState2 == LOW) {
  271.             if (BCDState3 == HIGH) {
  272.               if (BCDState4 == LOW) {
  273.                 S5 = 1;
  274.                
  275.               }
  276.             }
  277.           }
  278.         }
  279.        
  280.         // detek 6
  281.         if (BCDState1 == LOW) {
  282.           if (BCDState2 == HIGH) {
  283.             if (BCDState3 == HIGH) {
  284.               if (BCDState4 == LOW) {
  285.                 S6 = 1;
  286.                
  287.               }
  288.             }
  289.           }
  290.         }
  291.        
  292.         // detek 7
  293.         if (BCDState1 == HIGH) {
  294.           if (BCDState2 == HIGH) {
  295.             if (BCDState3 == HIGH) {
  296.               if (BCDState4 == LOW) {
  297.                 S7 = 1;
  298.                
  299.               }
  300.             }
  301.           }
  302.         }
  303.        
  304.         // detek 8
  305.         if (BCDState1 == LOW) {
  306.           if (BCDState2 == LOW) {
  307.             if (BCDState3 == LOW) {
  308.               if (BCDState4 == HIGH) {
  309.                 S8 = 1;
  310.                
  311.               }
  312.             }
  313.           }
  314.         }
  315.        
  316.         // detek 9
  317.         if (BCDState1 == HIGH) {
  318.           if (BCDState2 == LOW) {
  319.             if (BCDState3 == LOW) {
  320.               if (BCDState4 == HIGH) {
  321.                 S9 = 1;
  322.                
  323.               }
  324.             }
  325.           }
  326.         }
  327.        
  328.         // detek *
  329.         if (BCDState1 == HIGH) {
  330.           if (BCDState2 == HIGH) {
  331.             if (BCDState3 == LOW) {
  332.               if (BCDState4 == HIGH) {
  333.                 SB0 = 1;
  334.                
  335.               }
  336.             }
  337.           }
  338.         }
  339.        
  340.         // detek #
  341.         if (BCDState1 == LOW) {
  342.           if (BCDState2 == LOW) {
  343.             if (BCDState3 == HIGH) {
  344.               if (BCDState4 == HIGH) {
  345.                 SP0 = 1;
  346.                
  347.               }
  348.             }
  349.           }
  350.         }
  351.  }
  352. } // END cekinput
  353.  
  354.  
  355. // password 347
  356. void cekkombinasi() {
  357.   if ( S3 == 1 ) {
  358.     D1 = 1;
  359.   }
  360.  
  361.   if ( D1 == 1 ) {
  362.     if ( S4  == 1 ) {
  363.       D2 = 1;
  364.     }
  365.   }
  366.  
  367.   if ( D2 == 1 ) {
  368.     if ( S7 == 1 ) {
  369.       D3 = 1;
  370.     }
  371.   }
  372.  
  373. // selain angka password reset aja cong  
  374.  
  375.  
  376.   if ( S4 == 1 ) {
  377.     if ( D1 == 0 ) {
  378.       resetkombinasi();
  379.     }
  380.   }
  381.  
  382.   if ( S7 == 1 ) {
  383.     if ( D2 == 0 ) {
  384.       resetkombinasi();
  385.     }
  386.   }
  387.  
  388. // lanjuutt
  389.  
  390.   if ( SP0 == 1 ) {
  391.     if ( D3 == 0 ) {
  392.       resetkombinasi();
  393.     }
  394.   }
  395.  
  396.   if ( SB0 == 1 ) {
  397.     if ( D3 == 0 ) {
  398.       resetkombinasi();
  399.     }
  400.   }
  401.  
  402.   if ( S0 == 1 ) {
  403.     if ( D3 == 0 ) {
  404.       resetkombinasi();
  405.     }
  406.   }
  407.  
  408.   if ( S1 == 1 ) {
  409.     if ( D3 == 0 ) {
  410.       resetkombinasi();
  411.     }
  412.   }
  413.  
  414.   if ( S2 == 1 ) {
  415.     if ( D3 == 0 ) {
  416.       resetkombinasi();
  417.     }
  418.   }
  419.  
  420.   // yang mengandung angka password disable ajah yaksz
  421.  
  422.   //if ( S3 == 1 ) {
  423.   //  if ( D3 == 0 ) {
  424.   //    resetkombinasi();
  425.   //  }
  426.   //}
  427.  
  428.   //if ( S4 == 1 ) {
  429.   //  if ( D3 == 0 ) {
  430.   //    resetkombinasi();
  431.   //  }
  432.   //}
  433.  
  434.   if ( S5 == 1 ) {
  435.     if ( D3 == 0 ) {
  436.       resetkombinasi();
  437.     }
  438.   }
  439.  
  440.   if ( S6 == 1 ) {
  441.     if ( D3 == 0 ) {
  442.       resetkombinasi();
  443.     }
  444.   }
  445.  
  446.   //if ( S7 == 1 ) {
  447.   //  if ( D3 == 0 ) {
  448.   //    resetkombinasi();
  449.   //  }
  450.   //}
  451.  
  452.   if ( S8 == 1 ) {
  453.     if ( D3 == 0 ) {
  454.       resetkombinasi();
  455.     }
  456.   }
  457.  
  458.   if ( S9 == 1 ) {
  459.     if ( D3 == 0 ) {
  460.       resetkombinasi();
  461.     }
  462.   }
  463. } //END cekkombinasi
  464.  
  465. void cek6digit() {
  466.   if ( D3 == 1 ) {
  467.     if ( S0 == 1 ) {
  468.       U1 = 1;
  469.       //resetinput();
  470.       delay(300);
  471.     }
  472.   }
  473.  
  474.  
  475. if ( D3 == 1 ) {
  476.     if ( S1 == 1 ) {
  477.       V1 = 1;
  478.       //resetinput();
  479.       delay(300);
  480.     }
  481.   }
  482.  
  483.  
  484. if ( D3 == 1 ) {
  485.     if ( S2 == 1 ) {
  486.       W1 = 1;
  487.       //resetinput();
  488.       delay(300);
  489.     }
  490.   }
  491.  
  492.   if ( D3 == 1 ) {
  493.     if ( S3 == 1 ) {
  494.       X1 = 1;
  495.       //resetinput();
  496.       delay(300);
  497.     }
  498.   }
  499.  
  500.   if ( D3 == 1 ) {
  501.     if ( S4 == 1 ) {
  502.       Y1 = 1;
  503.       //resetinput();
  504.       delay(300);
  505.     }
  506.   }
  507.  
  508.   if ( D3 == 1 ) {
  509.     if ( S5 == 1 ) {
  510.       Z1 = 1;
  511.       //resetinput();
  512.       delay(300);
  513.     }
  514.   }
  515.  
  516.  
  517. resetinput();
  518. } // END cek 3 digit
  519.  
  520. void channelselect() {
  521.    // kepala 0
  522.    if ( U1 == 1 ) {
  523.      if      ( S1 == 1 ) { klir(); ch01(); EEPROM.write(100,1); resetsemuah(); }
  524.      else if ( S2 == 1 ) { klir(); ch02(); EEPROM.write(100,2); resetsemuah(); }
  525.      else if ( S3 == 1 ) { klir(); ch03(); EEPROM.write(100,3); resetsemuah(); }
  526.      else if ( S4 == 1 ) { klir(); ch04(); EEPROM.write(100,4); resetsemuah(); }
  527.      else if ( S5 == 1 ) { klir(); ch05(); EEPROM.write(100,5); resetsemuah(); }
  528.      else if ( S6 == 1 ) { klir(); ch06(); EEPROM.write(100,6); resetsemuah(); }
  529.      else if ( S7 == 1 ) { klir(); ch07(); EEPROM.write(100,7); resetsemuah(); }
  530.      else if ( S8 == 1 ) { klir(); ch08(); EEPROM.write(100,8); resetsemuah(); }
  531.      else if ( S9 == 1 ) { klir(); ch09(); EEPROM.write(100,9); resetsemuah(); }
  532.    } // END kepala 0
  533.    
  534. // kepala 1
  535.    if ( V1 == 1 ) {
  536.      if      ( S0 == 1 ) { klir(); ch10(); EEPROM.write(100,10); resetsemuah(); }
  537.      else if ( S1 == 1 ) { klir(); ch11(); EEPROM.write(100,11); resetsemuah(); }
  538.      else if ( S2 == 1 ) { klir(); ch12(); EEPROM.write(100,12); resetsemuah(); }
  539.      else if ( S3 == 1 ) { klir(); ch13(); EEPROM.write(100,13); resetsemuah(); }
  540.      else if ( S4 == 1 ) { klir(); ch14(); EEPROM.write(100,14); resetsemuah(); }
  541.      else if ( S5 == 1 ) { klir(); ch15(); EEPROM.write(100,15); resetsemuah(); }
  542.      else if ( S6 == 1 ) { klir(); ch16(); EEPROM.write(100,16); resetsemuah(); }
  543.      else if ( S7 == 1 ) { klir(); ch17(); EEPROM.write(100,17); resetsemuah(); }
  544.      else if ( S8 == 1 ) { klir(); ch18(); EEPROM.write(100,18); resetsemuah(); }
  545.      else if ( S9 == 1 ) { klir(); ch19(); EEPROM.write(100,19); resetsemuah(); }
  546.    } // END kepala 1
  547.      
  548.      
  549. // kepala 2
  550.    if ( W1 == 1 ) {
  551.      if      ( S0 == 1 ) { klir(); ch20(); EEPROM.write(100,20); resetsemuah(); }
  552.      else if ( S1 == 1 ) { klir(); ch21(); EEPROM.write(100,21); resetsemuah(); }
  553.      else if ( S2 == 1 ) { klir(); ch22(); EEPROM.write(100,22); resetsemuah(); }
  554.      else if ( S3 == 1 ) { klir(); ch23(); EEPROM.write(100,23); resetsemuah(); }
  555.      else if ( S4 == 1 ) { klir(); ch24(); EEPROM.write(100,24); resetsemuah(); }
  556.      else if ( S5 == 1 ) { klir(); ch25(); EEPROM.write(100,25); resetsemuah(); }
  557.      else if ( S6 == 1 ) { klir(); ch26(); EEPROM.write(100,26); resetsemuah(); }
  558.      else if ( S7 == 1 ) { klir(); ch27(); EEPROM.write(100,27); resetsemuah(); }
  559.      else if ( S8 == 1 ) { klir(); ch28(); EEPROM.write(100,28); resetsemuah(); }
  560.      else if ( S9 == 1 ) { klir(); ch29(); EEPROM.write(100,29); resetsemuah(); }
  561.    } // END kepala 2
  562.      
  563. // kepala 3
  564.    if ( X1 == 1 ) {
  565.      if      ( S0 == 1 ) { klir(); ch30(); EEPROM.write(100,30); resetsemuah(); }
  566.      else if ( S1 == 1 ) { klir(); ch31(); EEPROM.write(100,31); resetsemuah(); }
  567.    } // END kepala 3
  568.    
  569. // kepala 4
  570.    if ( Y1 == 1 ) {
  571.      if      ( S0 == 1 ) {  R1off(); EEPROM.write(41,0); resetsemuah(); }
  572.      else if ( S1 == 1 ) {  R1on();  EEPROM.write(41,1); resetsemuah(); }
  573.    } // END kepala 4
  574. // kepala 5
  575.    if ( Z1 == 1 ) {
  576.      if      ( S0 == 1 ) {  R2off(); EEPROM.write(51,0); resetsemuah(); }
  577.      else if ( S1 == 1 ) {  R2on();  EEPROM.write(51,1); resetsemuah(); }
  578.    } // END kepala 4      
  579.      
  580.  
  581. } // END channel select
  582.  
  583. // Relay 1 & 2
  584. void R1on() { digitalWrite(LedPin7, HIGH); }
  585. void R1off() { digitalWrite(LedPin7, LOW); }
  586. void R2on() { digitalWrite(LedPin8, HIGH); }
  587. void R2off() { digitalWrite(LedPin8, LOW); }
  588.  
  589. void ch01() {
  590.   digitalWrite(LedPin1, HIGH);
  591.   digitalWrite(LedPin2, LOW);
  592.   digitalWrite(LedPin3, LOW);
  593.   digitalWrite(LedPin4, LOW);
  594.   digitalWrite(LedPin5, LOW);
  595. }
  596.  
  597. void ch02() {
  598.   digitalWrite(LedPin1, LOW);
  599.   digitalWrite(LedPin2, HIGH);
  600.   digitalWrite(LedPin3, LOW);
  601.   digitalWrite(LedPin4, LOW);
  602.   digitalWrite(LedPin5, LOW);
  603. }
  604.  
  605. void ch03() {
  606.   digitalWrite(LedPin1, HIGH);
  607.   digitalWrite(LedPin2, HIGH);
  608.   digitalWrite(LedPin3, LOW);
  609.   digitalWrite(LedPin4, LOW);
  610.   digitalWrite(LedPin5, LOW);
  611. }
  612.  
  613. void ch04() {
  614.   digitalWrite(LedPin1, LOW);
  615.   digitalWrite(LedPin2, LOW);
  616.   digitalWrite(LedPin3, HIGH);
  617.   digitalWrite(LedPin4, LOW);
  618.   digitalWrite(LedPin5, LOW);
  619. }
  620.  
  621. void ch05() {
  622.   digitalWrite(LedPin1, HIGH);
  623.   digitalWrite(LedPin2, LOW);
  624.   digitalWrite(LedPin3, HIGH);
  625.   digitalWrite(LedPin4, LOW);
  626.   digitalWrite(LedPin5, LOW);
  627. }
  628.  
  629. void ch06() {
  630.   digitalWrite(LedPin1, LOW);
  631.   digitalWrite(LedPin2, HIGH);
  632.   digitalWrite(LedPin3, HIGH);
  633.   digitalWrite(LedPin4, LOW);
  634.   digitalWrite(LedPin5, LOW);
  635. }
  636.  
  637. void ch07() {
  638.   digitalWrite(LedPin1, HIGH);
  639.   digitalWrite(LedPin2, HIGH);
  640.   digitalWrite(LedPin3, HIGH);
  641.   digitalWrite(LedPin4, LOW);
  642.   digitalWrite(LedPin5, LOW);
  643. }
  644.  
  645. void ch08() {
  646.   digitalWrite(LedPin1, LOW);
  647.   digitalWrite(LedPin2, LOW);
  648.   digitalWrite(LedPin3, LOW);
  649.   digitalWrite(LedPin4, HIGH);
  650.   digitalWrite(LedPin5, LOW);
  651. }
  652.  
  653. void ch09() {
  654.   digitalWrite(LedPin1, HIGH);
  655.   digitalWrite(LedPin2, LOW);
  656.   digitalWrite(LedPin3, LOW);
  657.   digitalWrite(LedPin4, HIGH);
  658.   digitalWrite(LedPin5, LOW);
  659. }
  660.  
  661. void ch10() {
  662.   digitalWrite(LedPin1, LOW);
  663.   digitalWrite(LedPin2, HIGH);
  664.   digitalWrite(LedPin3, LOW);
  665.   digitalWrite(LedPin4, HIGH);
  666.   digitalWrite(LedPin5, LOW);
  667. }
  668.  
  669. void ch11() {
  670.   digitalWrite(LedPin1, HIGH);
  671.   digitalWrite(LedPin2, HIGH);
  672.   digitalWrite(LedPin3, LOW);
  673.   digitalWrite(LedPin4, HIGH);
  674.   digitalWrite(LedPin5, LOW);
  675. }
  676.  
  677. void ch12() {
  678.   digitalWrite(LedPin1, LOW);
  679.   digitalWrite(LedPin2, LOW);
  680.   digitalWrite(LedPin3, HIGH);
  681.   digitalWrite(LedPin4, HIGH);
  682.   digitalWrite(LedPin5, LOW);
  683. }
  684.  
  685. void ch13() {
  686.   digitalWrite(LedPin1, HIGH);
  687.   digitalWrite(LedPin2, LOW);
  688.   digitalWrite(LedPin3, HIGH);
  689.   digitalWrite(LedPin4, HIGH);
  690.   digitalWrite(LedPin5, LOW);
  691. }
  692.  
  693. void ch14() {
  694.   digitalWrite(LedPin1, LOW);
  695.   digitalWrite(LedPin2, HIGH);
  696.   digitalWrite(LedPin3, HIGH);
  697.   digitalWrite(LedPin4, HIGH);
  698.   digitalWrite(LedPin5, LOW);
  699. }
  700.  
  701. void ch15() {
  702.   digitalWrite(LedPin1, HIGH);
  703.   digitalWrite(LedPin2, HIGH);
  704.   digitalWrite(LedPin3, HIGH);
  705.   digitalWrite(LedPin4, HIGH);
  706.   digitalWrite(LedPin5, LOW);
  707. }
  708.  
  709.  
  710. void ch16() {
  711.   digitalWrite(LedPin1, LOW);
  712.   digitalWrite(LedPin2, LOW);
  713.   digitalWrite(LedPin3, LOW);
  714.   digitalWrite(LedPin4, LOW);
  715.   digitalWrite(LedPin5, HIGH);
  716. }
  717.  
  718. void ch17() {
  719.   digitalWrite(LedPin1, HIGH);
  720.   digitalWrite(LedPin2, LOW);
  721.   digitalWrite(LedPin3, LOW);
  722.   digitalWrite(LedPin4, LOW);
  723.   digitalWrite(LedPin5, HIGH);
  724. }
  725.  
  726. void ch18() {
  727.   digitalWrite(LedPin1, LOW);
  728.   digitalWrite(LedPin2, HIGH);
  729.   digitalWrite(LedPin3, LOW);
  730.   digitalWrite(LedPin4, LOW);
  731.   digitalWrite(LedPin5, HIGH);
  732. }
  733.  
  734. void ch19() {
  735.   digitalWrite(LedPin1, HIGH);
  736.   digitalWrite(LedPin2, HIGH);
  737.   digitalWrite(LedPin3, LOW);
  738.   digitalWrite(LedPin4, LOW);
  739.   digitalWrite(LedPin5, HIGH);
  740. }
  741.  
  742. void ch20() {
  743.   digitalWrite(LedPin1, LOW);
  744.   digitalWrite(LedPin2, LOW);
  745.   digitalWrite(LedPin3, HIGH);
  746.   digitalWrite(LedPin4, LOW);
  747.   digitalWrite(LedPin5, HIGH);
  748. }
  749.  
  750. void ch21() {
  751.   digitalWrite(LedPin1, HIGH);
  752.   digitalWrite(LedPin2, LOW);
  753.   digitalWrite(LedPin3, HIGH);
  754.   digitalWrite(LedPin4, LOW);
  755.   digitalWrite(LedPin5, HIGH);
  756. }
  757.  
  758. void ch22() {
  759.   digitalWrite(LedPin1, LOW);
  760.   digitalWrite(LedPin2, HIGH);
  761.   digitalWrite(LedPin3, HIGH);
  762.   digitalWrite(LedPin4, LOW);
  763.   digitalWrite(LedPin5, HIGH);
  764. }
  765.  
  766. void ch23() {
  767.   digitalWrite(LedPin1, HIGH);
  768.   digitalWrite(LedPin2, HIGH);
  769.   digitalWrite(LedPin3, HIGH);
  770.   digitalWrite(LedPin4, LOW);
  771.   digitalWrite(LedPin5, HIGH);
  772. }
  773.  
  774. void ch24() {
  775.   digitalWrite(LedPin1, LOW);
  776.   digitalWrite(LedPin2, LOW);
  777.   digitalWrite(LedPin3, LOW);
  778.   digitalWrite(LedPin4, HIGH);
  779.   digitalWrite(LedPin5, HIGH);
  780. }
  781.  
  782. void ch25() {
  783.   digitalWrite(LedPin1, HIGH);
  784.   digitalWrite(LedPin2, LOW);
  785.   digitalWrite(LedPin3, LOW);
  786.   digitalWrite(LedPin4, HIGH);
  787.   digitalWrite(LedPin5, HIGH);
  788. }
  789.  
  790. void ch26() {
  791.   digitalWrite(LedPin1, LOW);
  792.   digitalWrite(LedPin2, HIGH);
  793.   digitalWrite(LedPin3, LOW);
  794.   digitalWrite(LedPin4, HIGH);
  795.   digitalWrite(LedPin5, HIGH);
  796. }
  797.  
  798. void ch27() {
  799.   digitalWrite(LedPin1, HIGH);
  800.   digitalWrite(LedPin2, HIGH);
  801.   digitalWrite(LedPin3, LOW);
  802.   digitalWrite(LedPin4, HIGH);
  803.   digitalWrite(LedPin5, HIGH);
  804. }
  805.  
  806. void ch28() {
  807.   digitalWrite(LedPin1, LOW);
  808.   digitalWrite(LedPin2, LOW);
  809.   digitalWrite(LedPin3, HIGH);
  810.   digitalWrite(LedPin4, HIGH);
  811.   digitalWrite(LedPin5, HIGH);
  812. }
  813.  
  814. void ch29() {
  815.   digitalWrite(LedPin1, HIGH);
  816.   digitalWrite(LedPin2, LOW);
  817.   digitalWrite(LedPin3, HIGH);
  818.   digitalWrite(LedPin4, HIGH);
  819.   digitalWrite(LedPin5, HIGH);
  820. }
  821.  
  822. void ch30() {
  823.   digitalWrite(LedPin1, LOW);
  824.   digitalWrite(LedPin2, HIGH);
  825.   digitalWrite(LedPin3, HIGH);
  826.   digitalWrite(LedPin4, HIGH);
  827.   digitalWrite(LedPin5, HIGH);
  828. }
  829.  
  830. void ch31() {
  831.   digitalWrite(LedPin1, HIGH);
  832.   digitalWrite(LedPin2, HIGH);
  833.   digitalWrite(LedPin3, HIGH);
  834.   digitalWrite(LedPin4, HIGH);
  835.   digitalWrite(LedPin5, HIGH);
  836. }
  837.  
  838. void klir() {
  839.   digitalWrite(LedPin1, LOW);
  840.   digitalWrite(LedPin2, LOW);
  841.   digitalWrite(LedPin3, LOW);
  842.   digitalWrite(LedPin4, LOW);
  843.   digitalWrite(LedPin5, LOW);
  844. }
  845. void resetinput() {
  846.   S1 = 0;
  847.   S2 = 0;
  848.   S3 = 0;
  849.   S4 = 0;
  850.   S5 = 0;
  851.   S6 = 0;
  852.   S7 = 0;
  853.   S8 = 0;
  854.   S9 = 0;
  855.   SB0 = 0;
  856.   S0 = 0;
  857.   SP0 = 0;
  858. } // END resetinput
  859.  
  860.  
  861. void resetkombinasi() {  
  862.   D1 = 0;
  863.   D2 = 0;  
  864.   D3 = 0;
  865.   D4 = 0;
  866.   D5 = 0;
  867.   D6 = 0;
  868.   D7 = 0;
  869. } // END resetkombinasi
  870.  
  871. void resetkombinasi2() {
  872.   U1 = 0;
  873.   V1 = 0;
  874.   W1 = 0;
  875.   X1 = 0;
  876.   Y1 = 0;
  877.   Z1 = 0;
  878. }
  879.  
  880.  
  881. void remotedetect() {
  882. if ( D1 == 1 ) {digitalWrite(LedPin6, HIGH);}
  883. else if ( D1 == 0 ) {digitalWrite(LedPin6, LOW);}
  884. } // END remote detect
  885.  
  886. void resetsemuah() {
  887.   resetkombinasi();
  888.   resetkombinasi2();
  889.   resetinput();
  890. }
  891.  
  892. void loop(){
  893.  
  894.   // cek masukan angka dari DTMF
  895.   cekinput();
  896.   if ( SB0 || SP0 == 1 ) { resetsemuah(); }
  897.   // cek dulu D3 kalo on jangan cek lagi
  898.   if ( D3 == 1 ) {}
  899.   else {cekkombinasi();}
  900.   // cek dulu 6 digit kalo on jangan cek lagi
  901.   if      ( U1 == 1 ) {}
  902.   else if ( V1 == 1 ) {}
  903.   else if ( W1 == 1 ) {}
  904.   else if ( X1 == 1 ) {}
  905.   else if ( Y1 == 1 ) {}
  906.   else if ( Z1 == 1 ) {}
  907.   else    {cek6digit();}
  908.   // lanjut pilih channel
  909.   channelselect();
  910.   // reset variable inputan angka2
  911.   resetinput();
  912.   // running led logging sementaun
  913.   remotedetect();
  914.   delay(10);
  915. } // END loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement