#include <WiFi.h>

#define WIFI_SSID     "Wokwi-GUEST"
#define WIFI_PASSWORD ""

const int numLeds = 10;
int ledPins[numLeds] = {12, 14, 27, 26, 25, 33, 32, 35, 34, 13}; // Sesuaikan pin LED

void setup() {
  Serial.begin(115200);

  // Inisialisasi LED
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
    digitalWrite(ledPins[i], LOW);
  }

  // Menunggu Serial Monitor
  while (!Serial);

  Serial.println("Mulai scanning WiFi...");
  scanWiFi();
}

void loop() {
  // Loop utama, tidak melakukan apa-apa
}

void scanWiFi() {
  int networksFound = WiFi.scanNetworks();

  if (networksFound == 0) {
    Serial.println("Tidak ada WiFi yang ditemukan.");
  } else {
    Serial.print(networksFound);
    Serial.println(" WiFi networks ditemukan:");

    for (int i = 0; i < networksFound; ++i) {
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.println(" dBm)");
    }

    // Menjalankan indikator LED
    runLeds();
  }
}

void runLeds() {
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], HIGH);
    delay(100);
    digitalWrite(ledPins[i], LOW);
  }
}