Browse Source

add WiFi

split_files
Hendrik Langer 5 years ago
parent
commit
068b61e389
  1. 28
      src/main.cpp

28
src/main.cpp

@ -5,24 +5,34 @@
*/
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>
// Set LED_BUILTIN if it is not defined by Arduino framework
// #define LED_BUILTIN 2
WiFiMulti wifiMulti;
void setup()
{
Serial.begin(115200);
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD);
wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2);
Serial.println("Connecting Wifi...");
if(wifiMulti.run() == WL_CONNECTED) {
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
if(wifiMulti.run() != WL_CONNECTED) {
Serial.println("WiFi not connected!");
delay(1000);
}
}

Loading…
Cancel
Save