Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include <Arduino.h>
  2.  
  3. #include <ESP8266WiFi.h>
  4. #include <ESP8266WiFiMulti.h>
  5.  
  6. #include <ESP8266HTTPClient.h>
  7.  
  8. #define USE_SERIAL Serial
  9.  
  10. ESP8266WiFiMulti WiFiMulti;
  11.  
  12. const int cRockPin = 1; // the number of the rock pushbutton pin
  13. const int cPaperPin = 2; // the number of the paper pushbutton pin
  14. const int cScissorsPin = 3; // the number of the scissors pushbutton pin
  15. int rockState = 0;
  16. int paperState = 0;
  17. int scissorsState = 0;
  18.  
  19. void setup() {
  20.  
  21. USE_SERIAL.begin(115200);
  22. WiFi.mode(WIFI_STA);
  23. WiFi.disconnect();
  24. WiFiMulti.addAP("arduino69", "password");
  25. pinMode(cRockPin, INPUT);
  26. pinMode(cPaperPin, INPUT);
  27. pinMode(cScissorsPin, INPUT);
  28.  
  29. }
  30.  
  31. void loop() {
  32. // wait for WiFi connection
  33. if((WiFiMulti.run() == WL_CONNECTED)) {
  34. rockState = digitalRead(cRockPin);
  35. paperState = digitalRead(cPaperPin);
  36. scissorsState = digitalRead(cScissorsPin);
  37. HTTPClient http;
  38. int httpCode;
  39.  
  40. if(rockState == 1){
  41. // press rock button to choose rock
  42. http.begin("http://192.168.4.1/rock");
  43. Serial.println("rock");
  44. } else if (paperState == 1){
  45. http.begin("http://192.168.4.1/paper");
  46. Serial.println("paper");
  47. } else if (scissorsState == 1){
  48. http.begin("http://192.168.4.1/scissors");
  49. Serial.println("scissors");
  50. }
  51. httpCode = http.GET();
  52.  
  53. http.end();
  54. delay(60);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement