Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Bridge.h>
- #include <Temboo.h>
- #include "TembooAccount.h" // contains Temboo account information, as described below
- int numRuns = 1; // Execution count, so this doesn't run forever
- int maxRuns = 100; // Maximum number of times the Choreo should be executed
- int ledPin1 = 13;
- int ledPin2 = 12;
- int potPin = A0;
- int potValue;
- String value;
- String statuss;
- void setup() {
- Serial.begin(9600);
- pinMode(ledPin1, OUTPUT);
- pinMode(ledPin2, OUTPUT);
- // For debugging, wait until the serial console is connected.
- delay(4000);
- while(!Serial);
- Bridge.begin();
- }
- void loop() {
- if (numRuns <= maxRuns) {
- Serial.println("Running UpdateRow - Run #" + String(numRuns++));
- potValue = analogRead(potPin);
- potValue = map(potValue, 0,1023,0,50);
- if(potValue >= 1){
- statuss = "Occupied";
- digitalWrite(ledPin1, HIGH);
- digitalWrite(ledPin2, HIGH);
- }else{
- statuss = "Vacant";
- digitalWrite(ledPin1, LOW);
- digitalWrite(ledPin2, LOW);
- }
- TembooChoreo UpdateRowChoreo;
- // Invoke the Temboo client
- UpdateRowChoreo.begin();
- // Set Temboo account credentials
- UpdateRowChoreo.setAccountName(TEMBOO_ACCOUNT);
- UpdateRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
- UpdateRowChoreo.setAppKey(TEMBOO_APP_KEY);
- // Set Choreo inputs
- UpdateRowChoreo.addInput("WorksheetId", "1");
- UpdateRowChoreo.addInput("Username", "olundkvist92@gmail.com");
- UpdateRowChoreo.addInput("Password", "beubcplkdhjnibtp");
- UpdateRowChoreo.addInput("Row", "2");
- UpdateRowChoreo.addInput("RowData", ""+value = String(potValue)+", "+statuss+"");
- UpdateRowChoreo.addInput("SpreadsheetKey", "1_fXVTDlSjC3P50tXk6qdgYfh7wj193TeoGycuG5ULdQ");
- // Identify the Choreo to run
- UpdateRowChoreo.setChoreo("/Library/Google/Spreadsheets/UpdateRow");
- // Run the Choreo; when results are available, print them to serial
- UpdateRowChoreo.run();
- while(UpdateRowChoreo.available()) {
- char c = UpdateRowChoreo.read();
- Serial.print(c);
- }
- UpdateRowChoreo.close();
- }
- Serial.println("Waiting...");
- delay(2000); // wait 30 seconds between UpdateRow calls
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement