Devices & Components
USB to micro USB cable
ESP32-WROOM-32E
Hardware & Tools
Arduino Cloud Create Agent
Arduino Cloud IOT
Software & Tools
Arduino Web Editor
ARDUINO IOT REMOTE
Project description
Code
esp32_rgb
c
Code to control RGB led of ESP32-S3-DevkitC-1
1#include "thingProperties.h" 2 3void setup() { 4 // Initialize serial and wait for port to open: 5 Serial.begin(9600); 6 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 7 delay(1500); 8 9 // Defined in thingProperties.h 10 initProperties(); 11 12 // Connect to Arduino IoT Cloud 13 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 14 15 /* 16 The following function allows you to obtain more information 17 related to the state of network and IoT Cloud connection and errors 18 the higher number the more granular information you’ll get. 19 The default is 0 (only errors). 20 Maximum is 4 21 */ 22 setDebugMessageLevel(2); 23 ArduinoCloud.printDebugInfo(); 24} 25 26void loop() { 27 ArduinoCloud.update(); 28 // Your code here 29} 30 31/* 32 Since LedRGB is READ_WRITE variable, onLedRGBChange() is 33 executed every time a new value is received from IoT Cloud. 34*/ 35void onLedRGBChange() 36{ 37 uint8_t r=0,g=0,b=0; 38 39 if(ledRGB.getSwitch()) 40 { 41 ledRGB.getValue().getRGB(r,g,b); 42 Serial.println("R:"+String(r)+" G:"+String(g)+ " B:"+String(b)); 43 neopixelWrite(RGB_BUILTIN, r, g, b); 44 } 45 else 46 { 47 neopixelWrite(RGB_BUILTIN, 0, 0, 0); //turn off led 48 } 49}
Comments
Only logged in users can leave comments