Adding functions
This commit is contained in:
parent
b907521f59
commit
20e85b9085
1 changed files with 17 additions and 0 deletions
|
@ -1,8 +1,12 @@
|
|||
#include <ESP32Servo.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
Servo myservo; // create servo object to control a servo
|
||||
int servoPin = 18;
|
||||
|
||||
const char* ssid = "dlink";
|
||||
const char* password = "";
|
||||
|
||||
void closeCircuitAndOpen(int closeTime=400)
|
||||
{
|
||||
int pos = 0;
|
||||
|
@ -20,6 +24,8 @@ void closeCircuitAndOpen(int closeTime=400)
|
|||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
//======SERVO PART======//
|
||||
// Allow allocation of all timers
|
||||
ESP32PWM::allocateTimer(0);
|
||||
ESP32PWM::allocateTimer(1);
|
||||
|
@ -28,6 +34,17 @@ void setup()
|
|||
myservo.setPeriodHertz(50); // standard 50 hz servo
|
||||
myservo.attach(servoPin, 1000, 2000); // attaches the servo on pin 18 to the servo object
|
||||
myservo.write(0);delay(2500); // position to initial suitable position
|
||||
//======WIFI PART======/
|
||||
WiFi.mode(WIFI_STA); //Optional
|
||||
WiFi.begin(ssid, password);
|
||||
Serial.println("\nConnecting");
|
||||
while(WiFi.status() != WL_CONNECTED){
|
||||
Serial.print(".");
|
||||
delay(100);
|
||||
}
|
||||
Serial.println("\nConnected to the WiFi network");
|
||||
Serial.print("Local ESP32 IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
|
Loading…
Reference in a new issue