timor2542

IPST-SE with Random LED8 (Can select amount of the LEDs)

May 31st, 2018
182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ipst.h>
  2. #define LED8pin1 24
  3. #define CHSW 17
  4. #define CHSOUND 16
  5. #define CHSTATUS 18
  6. int time,ch,RANDOM;
  7. unsigned int i=0;
  8. unsigned int LED8_1L[8]={1,2,4,8,16,32,64,128};
  9. unsigned int LED8_2L[28]={3,5,6,9,10,12,17,18,
  10. 20,24,33,34,36,40,48,65,66,68,72,80,
  11. 96,129,130,132,136,144,160,192};
  12. unsigned int LED8_3L[56]={
  13.         7,11,13,14,19,21,22,25,26,28,35,37,38,41,42,44,49,
  14.     50,52,56,67,69,70,73,74,76,81,82,84,88,97,98,100,104,
  15.     112,131,133,134,137,138,140,145,146,148,152,161,162,
  16.     164,168,176,193,194,196,200,208,224};
  17. unsigned int LED8_4L[70]={
  18.         15,23,27,29,30,39,43,45,46,51,53,54,57,58,60,
  19.     71,75,77,78,83,85,86,89,90,92,99,101,102,105,
  20.     106,108,113,114,116,120,135,139,141,142,147,
  21.     149,150,153,154,156,163,165,166,169,170,172,
  22.     177,178,180,184,195,197,198,201,202,204,209,
  23.     210,212,216,225,226,228,232,240};
  24. unsigned int LED8_5L[56]={
  25.         31,47,55,59,61,62,79,87,91,93,94,103,107,109,110,115,
  26.     117,118,121,122,124,143,151,155,157,158,167,171,173,
  27.     174,179,181,182,185,186,188,199,203,205,206,211,213,
  28.     214,217,218,220,227,229,230,233,234,236,241,242,244,
  29.     248};
  30. unsigned int LED8_6L[28]={
  31.         63,95,111,119,123,125,126,159,175,183,187,189,190,207,
  32.     215,219,221,222,231,235,237,238,243,245,246,249,250,252
  33. };
  34. unsigned int LED8_7L[8]={127,191,223,239,247,251,253,254};
  35. unsigned int LED8_8L[1]={255};
  36. void setup()
  37. {
  38.   OKSW();// Wait for OK button
  39.   setTextColor(GLCD_GREEN);
  40.   setTextSize(23);
  41. }
  42.  
  43. void loop()
  44. {
  45.   glcd(0,0,"%d",knob(1,8));
  46.   if(sw_OK()){
  47.     out(CHSTATUS,1);
  48.     sound(800,100);
  49.   switch(knob(1,8))
  50.   {
  51.     case 1:
  52.     for(time=0;time<25;time++)
  53.     {
  54.     RANDOM=random(8);
  55.      LED8(LED8pin1,LED8_1L[RANDOM]);
  56.      delay(random(50,75));
  57.     }
  58.      break;
  59.      case 2:
  60.     for(time=0;time<25;time++)
  61.     {
  62.     RANDOM=random(28);
  63.      LED8(LED8pin1,LED8_2L[RANDOM]);
  64.      delay(random(50,75));
  65.     }
  66.      break;
  67.      case 3:
  68.     for(time=0;time<25;time++)
  69.     {
  70.     RANDOM=random(56);
  71.      LED8(LED8pin1,LED8_3L[RANDOM]);
  72.      delay(random(50,75));
  73.     }
  74.      break;
  75.      case 4:
  76.     for(time=0;time<25;time++)
  77.     {
  78.     RANDOM=random(70);
  79.      LED8(LED8pin1,LED8_4L[RANDOM]);
  80.      delay(random(50,75));
  81.     }
  82.      break;
  83.      case 5:
  84.     for(time=0;time<25;time++)
  85.     {
  86.     RANDOM=random(56);
  87.      LED8(LED8pin1,LED8_5L[RANDOM]);
  88.      delay(random(50,75));
  89.     }
  90.      break;
  91.      case 6:
  92.     for(time=0;time<25;time++)
  93.     {
  94.     RANDOM=random(28);
  95.      LED8(LED8pin1,LED8_6L[RANDOM]);
  96.      delay(random(50,75));
  97.     }
  98.      break;
  99.      case 7:
  100.     for(time=0;time<25;time++)
  101.     {
  102.     RANDOM=random(8);
  103.      LED8(LED8pin1,LED8_7L[RANDOM]);
  104.      delay(random(50,75));
  105.     }
  106.      break;
  107.      case 8:
  108.     for(time=0;time<25;time++)
  109.     {
  110.      LED8(LED8pin1,LED8_8L[0]);
  111.     }
  112.      break;
  113.      default: break;
  114.     }
  115.     out(CHSTATUS,0);
  116.   }
  117. }
RAW Paste Data