Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. #include <Bridge.h>
  2. #include <Temboo.h>
  3. #include "TembooAccount.h" // contains Temboo account information, as described below
  4.  
  5. int numRuns = 1; // Execution count, so this doesn't run forever
  6. int maxRuns = 100; // Maximum number of times the Choreo should be executed
  7.  
  8. int ledPin1 = 13;
  9. int ledPin2 = 12;
  10. int potPin = A0;
  11. int potValue;
  12. String value;
  13. String statuss;
  14.  
  15. void setup() {
  16. Serial.begin(9600);
  17.  
  18. pinMode(ledPin1, OUTPUT);
  19. pinMode(ledPin2, OUTPUT);
  20.  
  21. // For debugging, wait until the serial console is connected.
  22. delay(4000);
  23. while(!Serial);
  24. Bridge.begin();
  25. }
  26.  
  27. void loop() {
  28.  
  29. if (numRuns <= maxRuns) {
  30. Serial.println("Running UpdateRow - Run #" + String(numRuns++));
  31.  
  32. potValue = analogRead(potPin);
  33. potValue = map(potValue, 0,1023,0,50);
  34.  
  35. if(potValue >= 1){
  36. statuss = "Occupied";
  37. digitalWrite(ledPin1, HIGH);
  38. digitalWrite(ledPin2, HIGH);
  39. }else{
  40. statuss = "Vacant";
  41. digitalWrite(ledPin1, LOW);
  42. digitalWrite(ledPin2, LOW);
  43. }
  44.  
  45. TembooChoreo UpdateRowChoreo;
  46.  
  47. // Invoke the Temboo client
  48. UpdateRowChoreo.begin();
  49.  
  50. // Set Temboo account credentials
  51. UpdateRowChoreo.setAccountName(TEMBOO_ACCOUNT);
  52. UpdateRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
  53. UpdateRowChoreo.setAppKey(TEMBOO_APP_KEY);
  54.  
  55. // Set Choreo inputs
  56. UpdateRowChoreo.addInput("WorksheetId", "1");
  57. UpdateRowChoreo.addInput("Username", "olundkvist92@gmail.com");
  58. UpdateRowChoreo.addInput("Password", "beubcplkdhjnibtp");
  59. UpdateRowChoreo.addInput("Row", "2");
  60. UpdateRowChoreo.addInput("RowData", ""+value = String(potValue)+", "+statuss+"");
  61. UpdateRowChoreo.addInput("SpreadsheetKey", "1_fXVTDlSjC3P50tXk6qdgYfh7wj193TeoGycuG5ULdQ");
  62.  
  63. // Identify the Choreo to run
  64. UpdateRowChoreo.setChoreo("/Library/Google/Spreadsheets/UpdateRow");
  65.  
  66. // Run the Choreo; when results are available, print them to serial
  67. UpdateRowChoreo.run();
  68.  
  69. while(UpdateRowChoreo.available()) {
  70. char c = UpdateRowChoreo.read();
  71. Serial.print(c);
  72. }
  73. UpdateRowChoreo.close();
  74. }
  75.  
  76. Serial.println("Waiting...");
  77. delay(2000); // wait 30 seconds between UpdateRow calls
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement