Professional Documents
Culture Documents
CayennePhotoresistorExample
Thissketchshowshowtoautomaticallysenddatatoa
PhotoresistorSensorintheCayenneDashboard.
TheCayenneLibraryisrequiredtorunthissketch.Ifyouhave
notalreadydonesoyoucaninstallitfromtheArduinoIDE
LibraryManager.
Steps:
1.IntheCayenneDashboardaddanewPhotoresistorwidget.
2.SetthewidgettoValueDisplay.
3.SelecttheIntegratedADCandapinnumber.
4.AttachaphotoresistortotheanalogpinonyourArduino
matchingtheselectedpin.
Makesuretouseananalogpin,notadigitalpin.
Schematic:
[Ground][10kresistor]|[Photoresistor][5V]
|
AnalogPin
5.SetthetokenvariabletomatchtheArduinotokenfromthe
Dashboard.
6.Compileanduploadthissketch.
7.OncetheArduinoconnectstotheDashboarditshould
automaticallyupdatethePhotoresistorwidgetwithdata.
*/
#defineCAYENNE_PRINTSerial//Commentthisouttodisable
printsandsavespace
//Ifyou'renotusingtheEthernetW5100shield,changethisto
matchyourconnectiontype.SeeCommunicationsexamples.
#include<CayenneSerial.h>
//Cayenneauthenticationtoken.Thisshouldbeobtainedfromthe
CayenneDashboard.
chartoken[]="z83ebfkriy";
voidsetup()
{
Serial.begin(9600);
Cayenne.begin(token);
}
voidloop()
{
Cayenne.run();
}