Hi! (Sorry for bad english)
I started a project where by i have a RGB LED and i added 3 Luminosity widgets but i cant get them to work together.
When i entered the code they only work 1 by 1
This is the code. Please tell me what to add in so i can make virtual 1,2 and 3 work simultaneously
I plugged in my RGB LED to 3(Red),5(Blue),6(Green)
Steps:
- In the Cayenne Dashboard add a new Custom Widget, and select Slider.
- Select a virtual pin number.
- Set the slider widget min value to 0 and max value of 255.
- Set LED_VIRTUAL_PIN to the pin number you selected.
- Connect the LEDâs legs to GND, and to a PWM pin (3, 5, 6, 9, 10, and 11 on most Arduino boards).
Use a 1k resistor if possible.
Schematic:
[Ground] â [LED] â [1k-resistor] â [PWM Pin] - Set LED_DIGITAL_PIN to the PWM pin number you selected.
- Set the token variable to match the Arduino token from the Dashboard.
- Compile and upload this sketch.
- Once the Arduino connects to the Dashboard you can use the slider to change LED brightness.
*/
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
// If youâre not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
#include <CayenneEthernet.h>
#define LED_VIRTUAL_PIN 3
#define LED_DIGITAL_PIN 6
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = âAuthenticationTokenâ;
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
}
CAYENNE_IN(LED_VIRTUAL_PIN)
{
// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 255
analogWrite(LED_DIGITAL_PIN, currentValue); // analogWrite accepts a value from 0 to 255
}
void loop()
{
Cayenne.run();
}