Skip to content
Snippets Groups Projects
PaperBoat.ino 1.72 KiB
Newer Older
#include <WiFi.h>            /* wifi functionality */
#include <Servo.h>           /* servo functionality */

const char* ssid = "lemur";            /* network name */
const char* password = "lemu"         /* network password */

const int SERVO_LEFT = D1;              /* declaring right and left servos */ 
const int SERVO_RIGHT = D2;
Servo servo_left;
Servo servo_right;

void setup() {

  Serial.begin(115200);             /* serial montiro of Arduino IDE */

  scanNetwork();                    /* scan available WiFi networks & print info about them*/
  connectToNetwork();             /* connect device to WiFi network*/

  Serial.println(WiFi.localIP());   /* ESP32 should have local IP, to get it, call localIP method of WiFi ectern variable */
  Serial.println(WiFi.macAddress()); /* call macAddress method on WiFi ectern variable */

  WiFi.disconnect(true);             /* pass value of true to disable WiFi */
  Serial.println(WiFi.localIP()); /* call method to get IP again to confirm disconnect from network and no IP assigned */

  servosWakeUp();
}

void setup() {                      /* code for boat servos (make a loop or command for it) */
  servo_left.attach(SERVO_LEFT);
  servo_right.attach(SERVO_RIGHT);
  servo_left.write(0);
  servo_right.write(180);
}

void servosWakeUp() {
  servo_left.attach(SERVO_LEFT);
  servo_right.attach(SERVO_RIGHT);
  servo_left.write(0);
  servo_right.write(180);
}

#include <Servo.h>

static const int SERVO-LEFT = D1;
static const int SERVO-RIGHT = D2;

Servo servo_left;
Servo servo_right;

void setup() {
    Serial.begin(115200);
    servo_left.attach(SERVO-LEFT);
    servo_right.attach(SERVO-RIGHT);
    servoMove();
}

void servoMove() {
    servo_left.write(0);
    servo_right.write(180);
}