RuiViana

HC595_One_Pin

Jul 17th, 2016
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-------------------------
  2. void setup()
  3. {
  4.   pinMode(2, OUTPUT);
  5.   digitalWrite(3, LOW);
  6. }
  7. //------------------------
  8. void loop()
  9. {
  10.   for (int i = 0; i < 24; i++)        // 24 bits  = 3 x HC595
  11.     {
  12.      BitOn();
  13.      delay(50);
  14.     }
  15.     for (int i = 0; i < 24; i++)       // 24 bits  = 3 x HC595
  16.     {
  17.      BitOff();
  18.      delay(50);
  19.     }
  20. }
  21. //---------------------------
  22. void BitOn()
  23. {
  24.   digitalWrite(2, LOW);           // Down port
  25.   delayMicroseconds(25);          // bit On  minimo 20 us maximo 70
  26.   digitalWrite(2, HIGH);          // Upper port
  27.   delayMicroseconds(50);          // Tempo minimo 50us
  28. }
  29. //---------------------------
  30. void BitOff()
  31. {
  32.   digitalWrite(2, LOW);           // Upper port
  33.   delayMicroseconds(120);         // bit off minimo 100 us maximo não tem
  34.   digitalWrite(2, HIGH);          // Upper port
  35.   delayMicroseconds(50);          // Tempo minimo 50us
  36. }
RAW Paste Data