troubleshooting help wanted ESP-01 RSSI Servo + LED
Posted: Sun Jan 17, 2016 11:38 am
I have no idea why this code isn't working... Please help troubleshoot!
Servo is supposed to move and stop when rssi is one way, but otherwise move back and stop.
optoisolator LED is supposed to light up when rssi is one way, then off otherwise.
Servo is supposed to move and stop when rssi is one way, but otherwise move back and stop.
optoisolator LED is supposed to light up when rssi is one way, then off otherwise.
Code: Select all
#include <Servo.h>
#include <ESP8266WiFi.h>
#include <SPI.h> //Not sure if needed for serial printing.
#include <Ticker.h>
#define servopin 2
int rssi = 0;
const char* ssid = "AI-THINKER_F53A7F";
const char* password = "";
Servo myServo;
void setup(){
Serial.begin(115200);
pinMode(0, OUTPUT);
digitalWrite(0, HIGH);
Serial.println("OPTO OFF");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
myServo.attach(2);
}
void loop() {
long rssi = WiFi.RSSI();
//Serial.print(rssi);
if (rssi > -80 && rssi < 0) {
digitalWrite(0, LOW);
Serial.println("OPTO ON");
myServo.write(160);
delay(5);
}
else
{
digitalWrite(0, HIGH);
Serial.println("OPTO OFF");
myServo.write(20);
}
}