/**
ESP32 + DHT22 Example for Wokwi
https://wokwi.com/arduino/projects/322410731508073042
*/
#include "WiFi.h"
int RedPin = 21;
int GreenPin = 19;
int BluePin = 18;
void setup() {
Serial.begin(115200);
pinMode(RedPin, OUTPUT);
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
}
void loop() {
Serial.println("scan start");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
//int n = WiFi.scanNetworks(false, false, false,20);
Serial.println("scan done");
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
if (WiFi.RSSI(i)<=-35&& WiFi.RSSI(i) >-45){
cyan();
}
else if (WiFi.RSSI(i)<=-45&& WiFi.RSSI(i) >-55){
white();
}
else if (WiFi.RSSI(i)<=-55){
white();
}
}
}
Serial.println("");
// Wait a bit before scanning again
}
void white () {
//set the LED pins to values that make white
analogWrite(RedPin, 255);
analogWrite(GreenPin, 255);
analogWrite(BluePin, 255);
Serial.println("White");
}
void blue () {
//set the LED pins to values that make blue
analogWrite(RedPin, 0);
analogWrite(GreenPin, 0);
analogWrite(BluePin, 255);
Serial.println("Blue");
}
void violet () {
//set the LED pins to values that make blue
analogWrite(RedPin, 238);
analogWrite(GreenPin, 130);
analogWrite(BluePin, 238);
Serial.println("Violet");
}
void gray () {
//set the LED pins to values that make blue
analogWrite(RedPin, 128);
analogWrite(GreenPin, 128);
analogWrite(BluePin, 128);
Serial.println("Gray");
}
void cyan () {
//set the LED pins to values that make cyan
analogWrite(RedPin, 0);
analogWrite(GreenPin, 255);
analogWrite(BluePin, 255);
Serial.println("Cyan");
}