Advertisement
hidekicker

Rabos arcade

Nov 19th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. //Essa é a programação que usei durante o Hanamachi, todos os rabos com as mesmas cores da base até a ponta.
  2. //Ele faz um arco-íris com base nas cores HSV, mudando o Hue e mantendo saturação e brilho no máximo
  3. //(pra ver se aparece melhor nos rabos =x)
  4.  
  5. #include <FastLED.h>
  6. //pinos de metade dos rabos
  7. #define REDPIN   11
  8. #define GREENPIN 10
  9. #define BLUEPIN 9
  10.  
  11. //pinos da outra metade dos rabos...todos eles ligados com tip140
  12. #define REDPIN2   3
  13. #define GREENPIN2 5
  14. #define BLUEPIN2 6
  15.  
  16. //variável do tempo para testar cada uma das cores da fita
  17. int t=1000;
  18.  
  19. //documentação
  20. //https://github.com/FastLED/FastLED/wiki/Controlling-leds
  21. //https://github.com/FastLED/FastLED/blob/dcbf39933f51a2a0e4dfa0a2b3af4f50040df5c9/examples/AnalogOutput/AnalogOutput.ino
  22. void showAnalogRGB( const CRGB& rgb)
  23. {
  24.   analogWrite(REDPIN,   rgb.r );
  25.   analogWrite(GREENPIN, rgb.g );
  26.   analogWrite(BLUEPIN,  rgb.b );
  27.  
  28.   analogWrite(REDPIN2,   rgb.r );
  29.   analogWrite(GREENPIN2, rgb.g );
  30.   analogWrite(BLUEPIN2,  rgb.b );
  31.  
  32. }
  33.  
  34. void loop()
  35. {
  36.  
  37. //rabos arcade - o loop dura 10s... 39ms cada cor
  38.  for (int cor = 0 ; cor <= 255; cor += 1)
  39.  {
  40.   showAnalogRGB( CHSV( cor, 255, 255) );
  41.     delay(39);
  42.  }
  43.  
  44. /*
  45.  //teste das cores - quando dá algo de errado, testo por aqui
  46.   analogWrite(BLUEPIN, 0);    analogWrite(REDPIN, 255);    
  47.   analogWrite(BLUEPIN2, 0);    analogWrite(REDPIN2, 255);     delay(t);
  48.  
  49.   analogWrite(REDPIN, 0);     analogWrite(GREENPIN, 255);  
  50.   analogWrite(REDPIN2, 0);     analogWrite(GREENPIN2, 255);   delay(t);
  51.  
  52.   analogWrite(GREENPIN, 0);   analogWrite(BLUEPIN, 255);
  53.   analogWrite(GREENPIN2, 0);   analogWrite(BLUEPIN2, 255);
  54.  
  55.   delay(t);  delay(t);  delay(t);  delay(t);
  56. */
  57.  
  58. }
  59.  
  60. void setup()
  61. {
  62.   FastLED.setBrightness(180);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement