Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #include <ESP8266WiFi.h>
- #include <ESP8266WiFiMulti.h>
- #include <ESP8266HTTPClient.h>
- #define USE_SERIAL Serial
- ESP8266WiFiMulti WiFiMulti;
- const int cRockPin = 1; // the number of the rock pushbutton pin
- const int cPaperPin = 2; // the number of the paper pushbutton pin
- const int cScissorsPin = 3; // the number of the scissors pushbutton pin
- int rockState = 0;
- int paperState = 0;
- int scissorsState = 0;
- void setup() {
- USE_SERIAL.begin(115200);
- WiFi.mode(WIFI_STA);
- WiFi.disconnect();
- WiFiMulti.addAP("arduino69", "password");
- pinMode(cRockPin, INPUT);
- pinMode(cPaperPin, INPUT);
- pinMode(cScissorsPin, INPUT);
- }
- void loop() {
- // wait for WiFi connection
- if((WiFiMulti.run() == WL_CONNECTED)) {
- rockState = digitalRead(cRockPin);
- paperState = digitalRead(cPaperPin);
- scissorsState = digitalRead(cScissorsPin);
- HTTPClient http;
- int httpCode;
- if(rockState == 1){
- // press rock button to choose rock
- http.begin("http://192.168.4.1/rock");
- Serial.println("rock");
- } else if (paperState == 1){
- http.begin("http://192.168.4.1/paper");
- Serial.println("paper");
- } else if (scissorsState == 1){
- http.begin("http://192.168.4.1/scissors");
- Serial.println("scissors");
- }
- httpCode = http.GET();
- http.end();
- delay(60);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement