Advertisement
pleasedontcode

**WiFi Control** rev_02

Dec 3rd, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **WiFi Control**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-12-04 05:29:24
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* it should blink in red, blue and green every 2 */
  21.     /* seconds */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>    //https://github.com/m5stack/STAMP-PICO.git
  28. #include <WiFi.h> //include WiFi library
  29. #include <FastLED.h> //include FastLED library
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  36.  
  37. #define LED_PIN 5 //define LED pin
  38. #define NUM_LEDS 10 //define number of LEDs
  39. #define LED_TYPE WS2812B //define LED type
  40. #define COLOR_ORDER GRB //define LED color order
  41.  
  42. CRGB leds[NUM_LEDS]; //create array for LEDs
  43.  
  44. const char* ssid = "Your WiFi Network Name"; //WiFi network name
  45. const char* password = "Your WiFi Network Password"; //WiFi network password
  46.  
  47. void setup(void)
  48. {
  49.     // put your setup code here, to run once:
  50.     Serial.begin(115200); //initialize serial communication
  51.     FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS); //initialize FastLED library
  52.     WiFi.begin(ssid, password); //connect to WiFi network
  53.     while (WiFi.status() != WL_CONNECTED) { //wait for WiFi connection
  54.         delay(500);
  55.         Serial.println("Connecting to WiFi..");
  56.     }
  57.     Serial.println("Connected to WiFi!");
  58. }
  59.  
  60. void loop(void)
  61. {
  62.     // Blink in red, blue, and green every 2 seconds
  63.     for (int i = 0; i < NUM_LEDS; i++) {
  64.         leds[i] = CRGB::Red; // Set all LEDs to red
  65.     }
  66.     FastLED.show(); // Update LEDs with new color
  67.     delay(2000); // Wait for 2 seconds
  68.  
  69.     for (int i = 0; i < NUM_LEDS; i++) {
  70.         leds[i] = CRGB::Blue; // Set all LEDs to blue
  71.     }
  72.     FastLED.show(); // Update LEDs with new color
  73.     delay(2000); // Wait for 2 seconds
  74.  
  75.     for (int i = 0; i < NUM_LEDS; i++) {
  76.         leds[i] = CRGB::Green; // Set all LEDs to green
  77.     }
  78.     FastLED.show(); // Update LEDs with new color
  79.     delay(2000); // Wait for 2 seconds
  80. }
  81.  
  82. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement