Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **WiFi Control**
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2024-12-04 05:29:24
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* it should blink in red, blue and green every 2 */
- /* seconds */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h> //https://github.com/m5stack/STAMP-PICO.git
- #include <WiFi.h> //include WiFi library
- #include <FastLED.h> //include FastLED library
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- #define LED_PIN 5 //define LED pin
- #define NUM_LEDS 10 //define number of LEDs
- #define LED_TYPE WS2812B //define LED type
- #define COLOR_ORDER GRB //define LED color order
- CRGB leds[NUM_LEDS]; //create array for LEDs
- const char* ssid = "Your WiFi Network Name"; //WiFi network name
- const char* password = "Your WiFi Network Password"; //WiFi network password
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(115200); //initialize serial communication
- FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS); //initialize FastLED library
- WiFi.begin(ssid, password); //connect to WiFi network
- while (WiFi.status() != WL_CONNECTED) { //wait for WiFi connection
- delay(500);
- Serial.println("Connecting to WiFi..");
- }
- Serial.println("Connected to WiFi!");
- }
- void loop(void)
- {
- // Blink in red, blue, and green every 2 seconds
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CRGB::Red; // Set all LEDs to red
- }
- FastLED.show(); // Update LEDs with new color
- delay(2000); // Wait for 2 seconds
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CRGB::Blue; // Set all LEDs to blue
- }
- FastLED.show(); // Update LEDs with new color
- delay(2000); // Wait for 2 seconds
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CRGB::Green; // Set all LEDs to green
- }
- FastLED.show(); // Update LEDs with new color
- delay(2000); // Wait for 2 seconds
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement