This is a script I made for the ESP8266 that uses the Wi-Fi chip and creates a new Access Point every 5 seconds in order to display a message on WiFi lists on nearby devices that looks like this:
The code is:
#include <ESP8266WiFi.h> const char* ssids[] = {"Never gonna give you up","Never gonna let you down","Never gonna run around","Never gonna make you cry","Never gonna say goodbye","Never gonna tell a lie"}; const char* pass = "pass_goes_here"; void setup() { // put your setup code here, to run once: Serial.begin(9600); int currentssidno = 0; while (true) { const char* ssid = ssids[currentssidno]; Serial.print("SSID: "); Serial.println(ssid); WiFi.softAP(ssid, pass); delay(5000); WiFi.softAPdisconnect(false); currentssidno = currentssidno + 1; if (currentssidno == 6) //please change this count if you change the amount of ssids { currentssidno = 0; } } } void loop() { }
The code is also on GitHub.
How can I improve this code? This is my second or third project with Arduino and I pretty much made it in 15 minutes and looking at it now, some parts feels like dirty code (especially the part where I switch reset the SSID counter), how can I improve this?
Extra resources: Wi-Fi Library, ESP8266 Arduino Core