Guest User

Untitled

a guest
Feb 13th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /*Things to do:
  2. 5 different inputs = 5 different outputs
  3. Figure out LED arrays, incorperate
  4. comment ALL THE CODE!!!!!!!!!!!!!!!!!!
  5. Make it fancy*/
  6.  
  7.  
  8. #include <TimerOne.h>
  9. #include <FastLED.h>
  10. #define NUM_LEDS 75
  11. #define LED_PIN 3
  12. #define BRIGHTNESS 75
  13. #define LED_TYPE NEOPIXEL
  14. #define COLOR_ORDER GRB
  15. #define UPDATES_PER_SECOND 2098
  16. CRGB leds[NUM_LEDS];
  17. const int pin5 = 5;
  18. const int pin6 = 6;
  19. const int pin7 = 7;
  20. const int pin8 = 8;
  21. const int pin9 = 9;
  22.  
  23.  
  24. void setup() {
  25. delay(3000);
  26. FastLED.addLeds<LED_TYPE, LED_PIN>(leds, NUM_LEDS);
  27. FastLED.setBrightness(BRIGHTNESS);
  28. pinMode(pin5, INPUT_PULLUP);
  29. pinMode(pin6, INPUT_PULLUP);
  30. pinMode(pin7, INPUT_PULLUP);
  31. pinMode(pin8, INPUT_PULLUP);
  32. pinMode(pin9, INPUT_PULLUP);
  33. }
  34. int getMode(int d5, int d6, int d7) {
  35. int rtn = 1;
  36.  
  37. if (d7 == 1 && d6 == 1 && d5 == 0) {
  38. rtn = 0;
  39. }
  40.  
  41. if (d7 == 1 && d6 == 1 && d5 == 1) {
  42. rtn = 1;
  43. }
  44.  
  45. return rtn;
  46. }
  47.  
  48. void loop() {
  49. int d5 = digitalRead(pin5);
  50. int d6 = digitalRead(pin6);
  51. int d7 = digitalRead(pin7);
  52. int mode = getMode(d5, d6, d7);
  53.  
  54. switch (mode)
  55. {
  56. case 0:
  57. leds[0] = CRGB::Green;
  58. leds[1] = CRGB::Green;
  59. leds[2] = CRGB::Green;
  60. leds[3] = CRGB::Green;
  61. leds[4] = CRGB::Green;
  62. leds[5] = CRGB::Green;
  63. leds[6] = CRGB::Green;
  64. leds[7] = CRGB::Green;
  65. //leds[8] = CRGB::Green;
  66. FastLED.show();
  67. //delay(50);
  68. break;
  69. case 1:
  70. leds[0] = CRGB::Red;
  71. leds[1] = CRGB::Red;
  72. leds[2] = CRGB::Red;
  73. leds[3] = CRGB::Red;
  74. leds[4] = CRGB::Red;
  75. leds[5] = CRGB::Red;
  76. leds[6] = CRGB::Red;
  77. leds[7] = CRGB::Red;
  78. //leds[8] = CRGB::Red;
  79. FastLED.show();
  80. //delay(50);
  81. break;
  82. /*case 6:
  83. leds[0] = CRGB::Green;
  84. FastLED.show();
  85. //delay(500);
  86. break;
  87. default:
  88. leds[0] = CRGB::Black;
  89. //FastLED.show();
  90. //delay(500);
  91. //break; */
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment