Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <Process.h>
  2.  
  3. // set pin numbers:
  4. const int buttonPin = 2; // the number of the pushbutton pin
  5. const int redPin = 3; // the number of the red LED
  6. const int greenPin = 4; // the number of the green LED
  7. const int ledPin = 13; // the number of the LED pin
  8.  
  9. // variables will change:
  10. int buttonState = 0; // variable for reading the pushbutton status
  11.  
  12. void setup() {
  13. // initialize the LED pin as an output:
  14. pinMode(ledPin, OUTPUT);
  15. pinMode(redPin, OUTPUT);
  16. pinMode(greenPin, OUTPUT);
  17. // initialize the pushbutton pin as an input:
  18. pinMode(buttonPin, INPUT);
  19. //Initialize Bridge
  20. Bridge.begin();
  21. //Initialize Serial
  22. Serial.begin(9600);
  23. //Wait until a Serial Monitor is connected.
  24. while (!Serial);
  25.  
  26. //
  27. }
  28.  
  29. void loop() {
  30. // read the state of the pushbutton value:
  31. buttonState = digitalRead(buttonPin);
  32.  
  33. // check if the pushbutton is pressed.
  34. // if it is, the buttonState is HIGH:
  35. if (buttonState == HIGH) {
  36. // turn LED on:
  37. digitalWrite(ledPin, HIGH);
  38. Process p;
  39. p.runShellCommand("/root/run.sh");
  40. // turn on some LED
  41. while(p.running());
  42. //
  43.  
  44.  
  45. Serial.print(p.exitValue());
  46.  
  47. if(p.exitValue() == 0) {
  48. Serial.print("Sucess");
  49. digitalWrite(greenPin, HIGH);
  50. } else {
  51. Serial.print("Fail Whale");
  52. digitalWrite(redPin, HIGH);
  53. }
  54.  
  55. } else {
  56. digitalWrite(ledPin, LOW);
  57. }
  58. /*
  59. // Print command output on the Serial.
  60. // A process output can be read with the stream methods
  61. while (p.available() > 0) {
  62. char c = p.read();
  63. Serial.print(c);
  64. }
  65. // Ensure the last bit of data is sent.
  66. Serial.flush();
  67. */
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement