SHARE
TWEET

Untitled

a guest Aug 26th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unsigned long int t = millis() / 100;
  2.  
  3. void setup() {
  4.  
  5.   Serial.begin(9600);
  6.  
  7.   for (int i = 2; i < 14; i++) {
  8.     pinMode(i, OUTPUT);
  9.     digitalWrite(i, 1);
  10.   }
  11.   delay(1500);
  12.   for (int i = 2; i < 14; i++) {
  13.     digitalWrite(i, 0);
  14.     delay(500);
  15.   }
  16.  
  17. }
  18.  
  19. void power ( int number ) {
  20.   int group = number / 2;
  21.   bool ON = number % 2;
  22.   if ( number == 99)
  23.     for (int i = 2; i < 14; i++)
  24.       digitalWrite(i, 1);
  25.  
  26.   switch ( group ) {
  27.     case 0:
  28.       for (int i = 2; i <= 5; i++)
  29.         digitalWrite(i, ON);
  30.       break;
  31.     case 1:
  32.       digitalWrite(8, ON);
  33.       break;
  34.     case 2:
  35.       digitalWrite(9, ON);
  36.       break;
  37.     case 3:
  38.       for (int i = 2; i <= 5; i++)
  39.         digitalWrite(i, ON);
  40.       break;
  41.     case 4:
  42.       digitalWrite(5, ON);
  43.       break;
  44.     case 5:
  45.       for (int i = 2; i <= 5; i++)
  46.         digitalWrite(i, ON);
  47.       break;
  48.     case 6:
  49.       digitalWrite(9, ON);
  50.       digitalWrite(4, ON);
  51.       digitalWrite(5, ON);
  52.       break;
  53.     case 7:
  54.       //28
  55.       digitalWrite(3, ON);
  56.       digitalWrite(4, ON);
  57.       digitalWrite(5, ON);
  58.       digitalWrite(5, ON);
  59.       break;
  60.     case 8:
  61.       //36
  62.       digitalWrite(4, ON);
  63.       digitalWrite(5, ON);
  64.       digitalWrite(5, ON);
  65.       break;
  66.     case 9:
  67.       digitalWrite(6, ON);
  68.       break;
  69.     case 10:
  70.       digitalWrite(3, ON);
  71.       digitalWrite(4, ON);
  72.       digitalWrite(5, ON);
  73.       digitalWrite(7, ON);
  74.       break;
  75.     case 11:
  76.       digitalWrite(4, ON);
  77.       digitalWrite(5, ON);
  78.       digitalWrite(9, ON);
  79.       break;
  80.     default:
  81.       break;
  82.   }
  83.   t = millis() / 100;
  84. }
  85.  
  86. void loop() {
  87.   if ( Serial.available() > 0) {
  88.     power(Serial.parseInt());
  89.   } else {
  90.     if ( millis() / 100 - t > 2000 )
  91.       for (int i = 2; i < 14; i++)
  92.         digitalWrite(i, 1);
  93.   }
  94. }
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