Cayenne Slider Bug Test (Arduino code)


/ Published in: C++
Save to your folder(s)

Testing the slider bug within Cayenne.
This is the Arduino code.


Copy this code and paste it in your HTML
  1. /*
  2. Cayenne Ethernet Example
  3.  
  4. This sketch connects to the Cayenne server using an Arduino Ethernet Shield W5100
  5. and runs the main communication loop.
  6.  
  7. 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.
  8.  
  9. Steps:
  10. 1. Set the token variable to match the Arduino token from the Dashboard.
  11. 2. Compile and upload this sketch.
  12.  
  13. For Cayenne Dashboard widgets using digital or analog pins this sketch will automatically
  14. send data on those pins to the Cayenne server. If the widgets use Virtual Pins, data
  15. should be sent to those pins using virtualWrites. Examples for sending and receiving
  16. Virtual Pin data are under the Basics folder.
  17. */
  18.  
  19. //#define CAYENNE_DEBUG // Uncomment to show debug messages
  20. #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
  21. #include <CayenneEthernet.h>
  22.  
  23. // Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
  24. char token[] = "AuthCode";
  25. int vPin1 = 0;
  26.  
  27. void setup()
  28. {
  29. Serial.begin(9600);
  30. Cayenne.begin(token);
  31. }
  32.  
  33. void loop()
  34. {
  35. Cayenne.run();
  36. }
  37.  
  38. CAYENNE_IN(V0){
  39. vPin1 = getValue.asInt();
  40. }
  41.  
  42. CAYENNE_OUT(V1){
  43. Cayenne.virtualWrite(V1, vPin1);
  44. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.