Emakerz

Emakerz lampe connectée

Dec 21st, 2020 (edited)
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. //VIA YOUTUBE : EMAKERZ
  2. //LINK OF MY VIDEO : https://youtu.be/7QHd0KTtKYA
  3.  
  4. #include "FastLED.h"
  5. #include <BlynkSimpleEsp8266.h>
  6. #define BLYNK_PRINT Serial
  7. #define FASTLED_ESP8266_RAW_PIN_ORDER
  8. #define NOMBRE_DE_LEDS 60
  9. #define LED_TYPE WS2812
  10. #define COLOR_ORDER GRB
  11. #define PIN1 2
  12.  
  13. CRGB leds1[NOMBRE_DE_LEDS];
  14. char auth[] = "code blynk (reçu par mail)";
  15. char ssid[] = "nom de votre réseau wifi";
  16. char pass[] = "MDP WIFI";
  17. int data=255;
  18. int r,g,b;
  19.  
  20. void setup()
  21. {
  22. Serial.begin(9600);
  23. Blynk.begin(auth, ssid, pass);
  24. FastLED.addLeds<LED_TYPE, PIN1, COLOR_ORDER>(leds1, NOMBRE_DE_LEDS).setCorrection( TypicalLEDStrip );
  25. }
  26.  
  27. BLYNK_WRITE(V1)
  28. {
  29. r = param[0].asInt();
  30. g = param[1].asInt();
  31. b = param[2].asInt();
  32.  
  33. static1(r, g, b,data);
  34. }
  35.  
  36. void loop()
  37. {
  38. Blynk.run();
  39. }
  40. BLYNK_WRITE(V2)
  41. {
  42. data = param.asInt();
  43. static1(r, g, b,data);
  44. }
  45. void static1(int r, int g, int b,int brightness)
  46. {
  47. FastLED.setBrightness(brightness);
  48. for (int i = 0; i < NOMBRE_DE_LEDS; i++ )
  49. {
  50. leds1[i] = CRGB(r, g, b);
  51. }
  52. FastLED.show();
  53. }
Add Comment
Please, Sign In to add comment