Advertisement
Guest User

GoPro remote

a guest
Dec 30th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1.  
  2. /**********************************************************************************
  3. * ESP8266 REMOTE for GoPro by Robert Stefanowicz - euerdesign.de 28 Dec 2015 *
  4. *********************************************************************************/
  5.  
  6. #include
  7.  
  8. /*********************************
  9. * YOUR SETTINGS *
  10. *********************************/
  11.  
  12. const char* ssid = "Go1337Pro"; //Your Wifi name (SSID)
  13. const char* password = "PASSWORD"; //Your WiFi password
  14. /*********************************
  15. * DO NOT CHANGE BELOW THIS LINE *
  16. *********************************/
  17. const char* host = "10.5.5.9";
  18. int delshort = 50;
  19. int dellong = 500;
  20. const int buttonPin = 0;
  21. int value;
  22. int buttonstate;
  23. int buttonstates;
  24. int camstates;
  25. int checked;
  26. const int buttonPins = 2;
  27. int values;
  28. int valuess;
  29. void setup() {
  30. Serial.begin(115200);
  31. delay(100);
  32. pinMode(buttonPin, INPUT);
  33. pinMode(buttonPins, INPUT);
  34. Serial.println();
  35. Serial.println();
  36. Serial.print("Connecting to ");
  37. Serial.println(ssid);
  38. WiFi.begin(ssid, password);
  39. while (WiFi.status() != WL_CONNECTED) {
  40. delay(500);
  41. Serial.print(".");
  42. }
  43. Serial.println("");
  44. Serial.println("WiFi connected");
  45. Serial.println("IP address: ");
  46. Serial.println(WiFi.localIP());
  47. }
  48. void loop() {
  49. delay(delshort);
  50. values = digitalRead(buttonPins);
  51.  
  52. if (buttonstates != values)
  53. {
  54. buttonstates = values;
  55. if (values == 1)
  56. { checked = 0;
  57. if (camstates == 1){camstates = 0; checked = 1;}
  58. if (camstates == 0){
  59. if (checked == 0) {camstates = 1;}
  60. }
  61. Serial.println("Aenderung");
  62. Serial.print("connecting to ");
  63. Serial.println(host);
  64. WiFiClient client;
  65. const int httpPort = 80;
  66. if (!client.connect(host, httpPort)) {
  67. Serial.println("connection failed");
  68. return;
  69. }
  70. String url = "/gp/gpControl/command/shutter?p=";
  71. url += camstates;
  72. Serial.print("Requesting URL: ");
  73. Serial.println(url);
  74. client.print(String("GET ") + url + " HTTP/1.1\r\n" +
  75. "Host: " + host + "\r\n" +
  76. "Connection: close\r\n\r\n");
  77. delay(10);
  78. Serial.println();
  79. Serial.println("closing connection");
  80.  
  81. }
  82. delay(dellong);
  83. valuess = digitalRead(buttonPins);
  84. if (valuess == 1)
  85. {
  86. camstates = 0;
  87. while(valuess == 1){
  88. delay(delshort);
  89. Serial.println("WHILE-LOOP");
  90. Serial.println(valuess);
  91. valuess = digitalRead(buttonPins);
  92.  
  93. }
  94.  
  95. Serial.println("BUTTON STATE CHANGE ");
  96. Serial.print("connecting to ");
  97. Serial.println(host);
  98. WiFiClient client;
  99. const int httpPort = 80;
  100. if (!client.connect(host, httpPort)) {
  101. Serial.println("connection failed");
  102. return;
  103. }
  104. String url = "/gp/gpControl/command/shutter?p=0";
  105. Serial.print("Requesting URL: ");
  106. Serial.println(url);
  107. client.print(String("GET ") + url + " HTTP/1.1\r\n" +
  108. "Host: " + host + "\r\n" +
  109. "Connection: close\r\n\r\n");
  110. delay(10);
  111. Serial.println();
  112. Serial.println("closing connection");
  113. }
  114.  
  115. }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement