Skip to content
Snippets Groups Projects
Commit c3ed0ad8 authored by Mel Avina-Beltran's avatar Mel Avina-Beltran
Browse files

Upload Paperboat Arduino Code for servos

parent 72f3c850
No related merge requests found
No preview for this file type
#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);
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment