daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int layer[3][9];//warstwy * wiersze
  2. const int katoda[3] = {9, 10, 11};//katody
  3. static inline void zeros()//zerowanie
  4. {
  5.     digitalWrite(9, LOW);
  6.     digitalWrite(10, LOW);
  7.     digitalWrite(11, LOW);
  8. }
  9. static inline void onces(int current_layer)//jedynkowanie
  10. {
  11.     digitalWrite(katoda[current_layer], HIGH);
  12. }
  13. void setup()
  14. {
  15.     for (int i = 0; i <= 11; i++)
  16.     {
  17.         pinMode(i, OUTPUT);
  18.         digitalWrite(i, LOW);
  19.     }
  20.     layer[0][0] = 1;
  21.     layer[1][4] = 1;
  22.     layer[2][8] = 1;
  23. }
  24. void loop()
  25. {
  26.     static uint8_t current_layer;   //aktualna warstwa
  27.     zeros();    //wywołanie funkcji ustawiającej 0
  28.     for (int i = 0; i < 9; i++)
  29.     {
  30.         digitalWrite(i, layer[current_layer][i]);
  31.     }
  32.     onces(current_layer);   //ustawia jedynkę tylko jedną na jednej z katod aktywując jedną warstwę
  33.     current_layer++;
  34.     if (current_layer == 3) current_layer = 0;
  35.     delay(1);
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top