Advertisement
Guest User

Act 3

a guest
Oct 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. int leds[] = {2,3,4,5,6,7,8,9,10,11,12,13};
  2. int currentled = 0;
  3. int lastled = 11;
  4. int add = 11;
  5. int direction = 1;
  6. int directionback = -1;
  7. int y=12;
  8. int z=0;
  9.  
  10. void setup() {
  11. for(int x=0; x<12; x++){
  12. pinMode(leds[x], OUTPUT);
  13. }
  14. Serial.begin(9600);
  15. }
  16.  
  17. void loop() {
  18. sequence1();
  19. sequence2();
  20. sequence3();
  21. sequence4();
  22. sequence5();
  23. sequence6();
  24.  
  25. }
  26.  
  27. void sequence1(){
  28. for(int x=0; x<12; x++){
  29. digitalWrite(leds[x], LOW);
  30. }
  31. for(int i=0; i<1; i++){
  32. Serial.print("Sequence1,Cycle");
  33. Serial.println(i+1);
  34. for(int x=0; x<12; x++){
  35. digitalWrite(leds[x], HIGH);
  36. delay(200);
  37. }
  38. for(int x=0; x<12; x++){
  39. digitalWrite(leds[x], LOW);
  40. delay(200);
  41. }
  42. }
  43. for(int x=0; x<12; x++){
  44. digitalWrite(leds[x], LOW);
  45. }
  46. delay(1000);
  47. }
  48.  
  49. void sequence2(){
  50. for(int x=0; x<=12; x++){
  51. digitalWrite(leds[x], LOW);
  52. }
  53. for(int i=0; i<2; i++){
  54. Serial.print("Sequence2,Cycle");
  55. Serial.println(i+1);
  56. for(int x=0; x<12; x++){
  57. if(x % 2){
  58. digitalWrite(leds[x], HIGH);
  59. }
  60. else{digitalWrite(leds[x], LOW);
  61. }
  62. }
  63. delay(1000);
  64. for(int x=0; x<12; x++){
  65. if((x & 0x01) == 0){
  66. digitalWrite(leds[x], HIGH);
  67. }
  68. else{digitalWrite(leds[x], LOW);
  69. }
  70. }
  71. delay(1000);
  72. }
  73. }
  74.  
  75. void sequence3(){
  76. int currentled = 0;
  77. int lastled = 11;
  78. for(int x=0; x<=12; x++){
  79. digitalWrite(leds[x], LOW);
  80. }
  81. for(int i=0; i<3; i++){
  82. y = 12;
  83. z = 0;
  84. Serial.print("Sequence3,Cycle");
  85. Serial.println(i+1);
  86. for(int x=0; x<11; x++){
  87. for(int currentled=0; currentled<y; currentled++){
  88. digitalWrite(leds[currentled], HIGH);
  89. delay(20);
  90. }
  91. y += directionback;
  92.  
  93. for(int lastled=12; lastled>z; lastled--){
  94. digitalWrite(leds[lastled], LOW);
  95. delay(20);
  96. }
  97. if(lastled == 10){lastled -= direction;}
  98. }
  99. }
  100. }
  101.  
  102. void sequence4(){
  103. for(int x=0; x<=12; x++){
  104. digitalWrite(leds[x], LOW);
  105. }
  106. for(int i=0; i<4; i++){
  107. Serial.print("Sequence4,Cycle");
  108. Serial.println(i+1);
  109. for(int x=0; x<5; x++){
  110. digitalWrite(leds[currentled], HIGH);
  111. digitalWrite(leds[lastled], HIGH);
  112. delay(500);
  113. currentled += direction;
  114. if(currentled == 5){direction = -1;}
  115. if(currentled == 0){direction = 1;}
  116. lastled += directionback;
  117. if(lastled == 11){directionback = -1;}
  118. if(lastled == 6){directionback = 1;}
  119. }
  120. for(int x=0; x<=12; x++){
  121. digitalWrite(leds[x], LOW);
  122. }
  123. }
  124. }
  125.  
  126. void sequence5(){
  127. for(int x=0; x<12; x++){
  128. digitalWrite(leds[x], LOW);
  129. }
  130. for(int i=0; i<5; i++){
  131. Serial.print("Sequence5,Cycle");
  132. Serial.println(i+1);
  133. for(int x=0; x<12; x++){
  134. digitalWrite(leds[x], HIGH);
  135. delay(200);
  136. digitalWrite(leds[x], LOW);
  137. }
  138. }
  139. }
  140.  
  141. void sequence6(){
  142. for(int x=0; x<=12; x++){
  143. digitalWrite(leds[x], LOW);
  144. }
  145. for(int i=0; i<6; i++){
  146. Serial.print("Sequence6,Cycle");
  147. Serial.println(i+1);
  148. for(int x=0; x<12; x++){
  149. if(x % 2){
  150. digitalWrite(leds[x], HIGH);
  151. delay(100);
  152. }
  153. }
  154. for(int x=0; x<12; x++){
  155. if((x & 0x01) == 0){
  156. digitalWrite(leds[x], HIGH);
  157. delay(100);
  158. }
  159. }
  160. delay(500);
  161. for(int x=0; x<12; x++){
  162. if(x % 2){
  163. digitalWrite(leds[x], LOW);
  164. delay(100);
  165. }
  166. }
  167. for(int x=0; x<12; x++){
  168. if((x & 0x01) == 0){
  169. digitalWrite(leds[x], LOW);
  170. delay(100);
  171. }
  172. }
  173. }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement