关于M5GO底座GPIO15引脚使用
M5GO底座GPIO15引脚连接Nexpixel LED,在使用15号引脚时,建议初始化时将引脚设置为OUTPUT_OPEN_DRAIN模式,已获得更好的信号质量#include "WiFi.h"
#include <M5Stack.h>
#include <Adafruit_NeoPixel.h>
#define M5STACK_FIRE_NEO_NUM_LEDS 10
#define M5STACK_FIRE_NEO_DATA_PIN 15
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(M5STACK_FIRE_NEO_NUM_LEDS, M5STACK_FIRE_NEO_DATA_PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
M5.begin();
pinMode(15, OUTPUT_OPEN_DRAIN);
pixels.begin();
// 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()
{
M5.Lcd.println("scan start");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
M5.Lcd.println("scan done");
if (n == 0) {
M5.Lcd.println("no networks found");
} else {
M5.Lcd.print(n);
M5.Lcd.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
M5.Lcd.print(i + 1);
M5.Lcd.print(": ");
M5.Lcd.print(WiFi.SSID(i));
M5.Lcd.print(" (");
M5.Lcd.print(WiFi.RSSI(i));
M5.Lcd.print(")");
M5.Lcd.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
static int pixelNumber=0;// = random(0, M5STACK_FIRE_NEO_NUM_LEDS - 1);
pixelNumber++;
if(pixelNumber>9)pixelNumber=0;
int r = 1<<random(0, 7);
int g = 1<<random(0, 7);
int b = 1<<random(0, 7);
pixels.setPixelColor(pixelNumber, pixels.Color(r, g, b));
pixels.show();
delay(10);
}
}
M5.Lcd.println("");
// Wait a bit before scanning again
delay(1000);
}
页:
[1]