Good day,
Im very new to arduino and coding the arduino so I wanted to start out simple.
I want to control a ws2812 rgb led with three sliders in Cayenne.
This is the code i got so far, but i get error massages.
I think the last bit is in a wrong spot, but i tried a lot of other places but got error massages again.
Can somebody tell me how the code should be?
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>
#include “FastLED.h”
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxxxxxxxxx”;
char password = “xxxxxxxxxx”;
char clientID = “xxxxxxxxxx”;
#define NUM_LEDS 1
#define VIRTUAL_CHANNEL1 10
#define VIRTUAL_CHANNEL2 11
#define VIRTUAL_CHANNEL3 12
#define ACTUATOR_PIN 6
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(115200);
FastLED.addLeds<WS2812, ACTUATOR_PIN, RGB>(leds, NUM_LEDS);
Cayenne.begin(username, password, clientID);
}
void loop()
{
Cayenne.loop();
}
// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL1)
{
int value1 = getValue.asInt(); // 0 to 255
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL1, ACTUATOR_PIN, value1);
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255.
analogWrite(ACTUATOR_PIN, value1);
}
CAYENNE_IN(VIRTUAL_CHANNEL2)
{
int value2 = getValue.asInt(); // 0 to 255
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL2, ACTUATOR_PIN, value2);
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255.
analogWrite(ACTUATOR_PIN, value2);
}
CAYENNE_IN(VIRTUAL_CHANNEL3)
{
int value3 = getValue.asInt(); // 0 to 255
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL3, ACTUATOR_PIN, value3);
// Write the value received to the PWM pin. analogWrite accepts a value from 0 to 255.
analogWrite(ACTUATOR_PIN, value3);
}
leds[0] = CRGB(value1,value2,value3);
FastLED.show();
delay(1000);