Advertisement
LEDPROJECT69420

Crappy Psuedocode for light

Aug 9th, 2020 (edited)
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. void loop() {
  2. // put your main code here, to run repeatedly:
  3.  
  4. }
  5.  
  6. //Psuedocode attempt to make an LED thingy
  7.  
  8.  
  9. // Importing needed libraries
  10. #include <FastLED.h>
  11. #include <IRremote.h>
  12.  
  13.  
  14. #define NUM_LEDS 300
  15. CRGB leds[NUM_LEDS];
  16. #define data_pin 5
  17.  
  18. // defining various zones. Zone 1 = Under cabinet, Zone 2 = Around window etc.
  19. zone1 = leds [0:24]
  20. zone2 = leds [24:172]
  21. zone3 = leds [173:277]
  22. zone4 = leds [278:299]
  23.  
  24. void setup() {
  25. // put your setup code here, to run once:
  26. FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  27. }
  28.  
  29.  
  30.  
  31. void preset1(){
  32. for led in zone1:
  33. ledRGB = (160, 0, 210)
  34. for led in zone2:
  35. ledRGB = (120, 0, 24)
  36. for led in zone3:
  37. ledRGB = (0, 0, 0)
  38. for led in zone4:
  39. ledRGB = (100,100,100)
  40. // Make a whole bunch more of these normal presets
  41.  
  42. Def preset6()
  43. for led in zone1:
  44. do cool fastled effect thing
  45. for led in zone2:
  46. do different fastled effect thing
  47. for led in zone3:
  48. ledRGB = (0, 0, 0)
  49. for led in zone4:
  50. ledRGB = (0, 0, 0)
  51.  
  52. // Make a whole bunch more of these fancy presets
  53.  
  54. Def BrightnessUp()
  55. i = 0
  56. for num_led in zone1 and zone2 and zone3 and zone4:
  57. if i in ledRGB > 0: //This is to minimise colour shift. Any RGB channel set at 0 won’t increase.
  58. i = i+10
  59. else:
  60. return
  61.  
  62. // Similar for brightness down
  63.  
  64.  
  65.  
  66. void setup() {
  67.     
  68.     FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  69. {
  70.  
  71.  
  72.  
  73. //The following is mostly copy pasted C++ code with modifications
  74. //It works to understand the IR remote inputs and call functions based on input
  75.  
  76. const int RECV_PIN = 7;
  77.  
  78. IRrecv irrecv(RECV_PIN);
  79. decode_results results;
  80. unsigned long key_value = 0;
  81.  
  82. void setup(){
  83. irrecv.enableIRIn();
  84. irrecv.blink13(true);
  85. }
  86.  
  87. void loop(){
  88. if (irrecv.decode(&results)){
  89.  
  90. if (results.value == 0XFFFFFFFF)
  91. results.value = key_value;
  92.  
  93. switch(results.value)
  94. case 0xFF30CF:
  95. Serial.println("1");
  96. Call preset1()
  97. break ;
  98. case 0xFF18E7:
  99. Serial.println("2");
  100. Call preset2()
  101. break ;
  102. case 0xFF7A85:
  103. Serial.println("3");
  104. Call preset3()
  105. break ;
  106. //ETC for every number on remote
  107. case 0xFFE01F:
  108. Serial.println("-");
  109. Call BrigtnessDown()
  110. break ;
  111. case 0xFFA857:
  112. Serial.println("+");
  113. Call BrightnessUp()
  114. break ;
  115.  
  116. }
  117. key_value = results.value;
  118. irrecv.resume();
  119. }
  120. }
  121.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement