First, I would like to thank you for your kind reply. I checked your code and found that this line was not in yours: #define CAYENNE_PRINT Serial
I removed that line from my sketch (as you also draw my attention with this: "make sure there is no serial activities going in pc ") and after upload it seems I managed to run the script correctly and Arduino went online. Could it be the issue? What do you think?
Anyway, here you can find my sketch:
Cayenne Luminosity Example
This sketch sample file shows how to change the brightness on a LED
using Cayenne Dashboard.
The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
- In the Cayenne Dashboard add a new Custom Widget, and select Slider.
- Select a virtual pin number.
- Set min value to 0 and max value of 1.
- 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.
[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 < CayenneSerial.h>
#define LED_VIRTUAL_PIN 1
#define LED_DIGITAL_PIN 3
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “0b7nyxjdhm”;
// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 1023
analogWrite(LED_DIGITAL_PIN, currentValue / 4); // must be from 0 to 255