SOLVED (after 6h) Version1.0:-)
This Guys helped a lot:
- Usare la piattaforma Arduino IoT Cloud per accendere un LED - Video 418 - YouTube
- Arduino Cloud
- wiring (first pic - https://www.instructables.com/Driving-RGB-LED-strips-off-an-Arduino/)
=> Dashboard: i created 3 x Dimmed light (3 Outputs r; g; b)
#include "thingProperties.h"
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode( 9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop() {
ArduinoCloud.update();
}
void onRChange() {
uint8_t brightness = map(r.getBrightness(), 0, 100, 0, 255);
if (r.getSwitch()){
Serial.println(brightness);
analogWrite(11, brightness);
}
else{
analogWrite(11,LOW);
}
}
void onGChange() {
uint8_t brightness = map(g.getBrightness(), 0, 100, 0, 255);
if (g.getSwitch()){
Serial.println(brightness);
analogWrite(10, brightness);
}
else{
analogWrite(10,LOW);
}
}
void onBChange() {
uint8_t brightness = map(b.getBrightness(), 0, 100, 0, 255);
if (b.getSwitch()){
Serial.println(brightness);
analogWrite(9, brightness);
}
else{
analogWrite(9,LOW);
}
}