Hi David.
Check out https://randomnerdtutorials.com/esp32-web-server-arduino-ide/ the tutorials on this site are very good and there are loads of them. Remember your M5paper is basically an ESP32 with a in built touch screen display.
Hi David.
Check out https://randomnerdtutorials.com/esp32-web-server-arduino-ide/ the tutorials on this site are very good and there are loads of them. Remember your M5paper is basically an ESP32 with a in built touch screen display.
@trrevvorr said in M5Stamp C3 programming examples:
M5Stamp-C3
While I realise it's a different core but I've been having fun with the M5Stamp-Pico which does use the same LED controller so I wonder if this will help with the ops question.
I use the Arduino-IDE and the FastLed module. I've attached a snippet of code where the LED is White while searching for the wifi and Green when connected. It then flashes Blue when data is received.
More about FastLed can be found here:
https://github.com/FastLED/FastLED
https://github.com/FastLED/FastLED/wiki/Pixel-reference#chsv
// Load Wi-Fi, Servo and Led libraries
#include <WiFi.h>
#include <ESP32Servo.h>
#include <FastLED.h>
#include <Preferences.h>
// number of leds on board and data pin
#define NUM_LEDS 1
#define LED_DATA_PIN 27
// Define the array of leds
CRGB leds[NUM_LEDS];
//Create Servo Object
Servo servo;
// Setup network credentials
const char* ssid = "SMCS";
const char* password = "**********";
// Set web server port number to 80
WiFiServer server(80);
// Variable to store the HTTP request
String header;
// Auxiliar variables to store the current output state
String SliderValue = "0"; // Contains returned value of Speed Slider range 0-1023
int Speed = 180; // Contains Integer value of Speed Slider range 0-180 deg for Servo
int OldSpeed = 180; // Contains previous speed
int Index; // String index
unsigned long time_now = 0; // Used to calculate time outs
String EngineName = "Millie"; // Engine name
// Assign output variables to GPIO pins
// M5 Stamp pin to GPIO Mapping used by Train Controller
// 5v positive 5 volt supply
// Gnd Ground Supply
// G32 GPI32 Servo Pin
const int ServoPin = G32; // Servo Drive GPI32
// Current time
unsigned long currentTime = millis();
// Previous time
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;
// Set-up
void setup() {
// Initialize the output variables as outputs
// Start with motor Drive control
servo.attach(ServoPin);
// Start the serial monitor
Serial.begin(115200);
// Set up Fastled and turn it To White
FastLED.addLeds<SK6812, LED_DATA_PIN, GRB>(leds, NUM_LEDS);
leds[0] = CRGB::White;
FastLED.show();
// Connect to Wi-Fi network with SSID and password
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
leds[0] = CRGB::Green;
FastLED.show();
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
// Main program
void loop() {
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects,
leds[0] = CRGB::Blue; // Go Blue
FastLED.show();
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client