Introduction: S3 Mini Pro Lolin Simple Projects + Bonus Catching Pumpkins Game!

About: I enjoy designing 3D models and printed circuit boards. I am an Electrical Engineer. I will share some cool projects & try out a few! #innovator

Whether you're new to microcontrollers or an experienced maker, these projects lay a solid foundation for further exploration into the S3 Mini Pro's advanced features, such as Wi-Fi, Bluetooth, and advanced I/O handling. There's so much more to come with this powerful microcontroller—this is just the beginning!

This project was created to provide content for the new S3 Mini Pro a WiFi & BLE board based on the ESP32-S3FH4R2 with 0.85 inch TFT Screen and IMU. Since there are not many tutorials available yet, I wanted to dive in with three fun LED projects.

Supplies

Step 1: Arduino IDE Setup

  1. Download the latest Arduino IDE

Installing using Arduino IDE

  1. Open the platform by double clicking to icon
  2. Under "Tools" - "Boards" add the ESP32 by Espressif
  3. esp32 arduino package

*Use the Development release link

Additional libraries may need to be installed for certain projects.

  1. TFT_eSPI
  2. AdaFruit
  3. etc.

Step 2: Blink Sketch

The Blink sketch is one of the simplest and most common starting projects for working with microcontrollers. It demonstrates how to control a digital output pin by turning an LED on and off at a regular interval. Here's how it works:

Overview:

  1. Pin 37 is used as the digital output pin to which the LED is connected.
  2. The LED is powered using the 3V pin from the microcontroller.
  3. The sketch alternates between turning the LED on and off, creating a blinking effect.


Step 3: Blink the Built-in RGB LED

/*

 Modified by: Bits4Bots LLC - Larsha Johnson

 BlinkRGB

 Demonstrates usage of onboard RGB LED on the S3 Mini Pro ESP dev boards.

 Calling digitalWrite(RGB_BUILTIN, HIGH) will use hidden RGB driver.

 RGBLedWrite demonstrates control of each channel:

 void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val)

 WARNING: After using digitalWrite to drive RGB LED it will be impossible to drive the same pin

  with normal HIGH/LOW level

*/

//#define RGB_BRIGHTNESS 64 // Change white brightness (max 255)

// the setup function runs once when you press reset or power the board

void setup() {

 // No need to initialize the RGB LED

  pinMode(7, OUTPUT); //Provide power to the WS2812B-0807 IC (RGB LED)

}

// the loop function runs over and over again forever

void loop() {

 digitalWrite(7, HIGH); //Send power to the WS2812B-0807 IC

#ifdef RGB_BUILTIN

 //digitalWrite(RGB_BUILTIN, HIGH); // Turn the RGB LED white

 //delay(1000);

 //digitalWrite(RGB_BUILTIN, LOW); // Turn the RGB LED off

 // delay(1000);

 neopixelWrite(RGB_BUILTIN, RGB_BRIGHTNESS, 0, 0); // Red

 delay(1000);

 neopixelWrite(RGB_BUILTIN, 0, 0, RGB_BRIGHTNESS); // Green - normally (0, 255, 0) is displayed as green but there internal wiring is flipped

 delay(1000);

 neopixelWrite(RGB_BUILTIN, 0, RGB_BRIGHTNESS, 0); // Blue - normally (0, 0, 255) is displayed as blue but there internal wiring is flipped

 delay(1000);

 //neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Off / black

 //delay(1000);

#endif

}


How It Works:

This code controls the onboard RGB LED on the S3 Mini Pro ESP32 microcontroller and demonstrates how to use the digitalWrite function to turn it on/off as well as how to control each color channel (red, green, blue) individually using the neopixelWrite function.

Breakdown of the code:

  1. Comment Section
  2. The comments describe the functionality of the code. It highlights that the onboard RGB LED is controlled using digitalWrite for basic on/off functionality, and neopixelWrite is used for controlling the color intensities of the RGB LED.
  3. There's a warning that after using digitalWrite to control the RGB LED, it won't be possible to drive the same pin with a simple HIGH/LOW signal.
  4. Setup Function
  5. pinMode(7, OUTPUT);: This configures pin 7 as an output. Pin 7 provides power to the RGB LED driver chip, which is the WS2812B-0807 IC.
  6. This means that the RGB LED will be ready to receive signals for color control.
  7. Loop Function
  8. The loop() function repeats continuously, providing power and alternating the RGB LED colors.
  9. digitalWrite(7, HIGH);: Sends power to the WS2812B RGB driver IC (via pin 7), making the RGB LED ready to operate.
  10. digitalWrite(RGB_BUILTIN, HIGH);: Turns the onboard RGB LED on, setting it to white because all color channels (R, G, B) are active at full intensity.
  11. delay(1000);: Introduces a 1-second delay before proceeding to the next command.
  12. digitalWrite(RGB_BUILTIN, LOW);: Turns off the RGB LED (all color channels are turned off).
  13. The next section demonstrates controlling each color channel individually with the neopixelWrite function:
  14. neopixelWrite(RGB_BUILTIN, RGB_BRIGHTNESS, 0, 0);: This command sets the RGB LED to red by turning on the red channel and turning off the green and blue channels.
  15. neopixelWrite(RGB_BUILTIN, 0, RGB_BRIGHTNESS, 0);: This sets the RGB LED to green.
  16. neopixelWrite(RGB_BUILTIN, 0, 0, RGB_BRIGHTNESS);: This sets the RGB LED to blue.
  17. neopixelWrite(RGB_BUILTIN, 0, 0, 0);: This turns off the RGB LED completely (black/off).
  18. Each of these color-changing steps is followed by a 1-second delay (delay(1000);).

Functions Explained:

  1. digitalWrite(pin, value):
  2. This is a standard Arduino function that sets the voltage on a specified pin to either HIGH (3.3V/5V) or LOW (0V).
  3. Here, it is used to turn the RGB LED on/off as well as provide power to the WS2812B IC.
  4. neopixelWrite(pin, red_val, green_val, blue_val):
  5. This custom function is used to control the individual red, green, and blue channels of the RGB LED.
  6. The values red_val, green_val, and blue_val specify the brightness of each color channel. The intensity typically ranges from 0 (off) to 255 (full brightness).
  7. In this case, RGB_BRIGHTNESS is used to define the brightness (default is 64).

Key Takeaways:

  1. The code first turns the RGB LED white, turns it off, then cycles through the red, green, and blue colors using the neopixelWrite function.
  2. The onboard RGB LED can be controlled using both basic HIGH/LOW digital commands and by setting specific color intensities for each channel.

This code is useful for learning how to control multicolor LEDs and can be extended to create more complex lighting patterns or effects.

Concept:

  1. By combining the three basic color channels (red, green, and blue), you can create a variety of colors. For now, this sketch simply demonstrates how to turn each channel on and off individually.

Extending the Sketch:

  1. You could modify this sketch to create custom colors by turning on multiple channels at once (e.g., red and green together will create yellow).

This basic project is a great way to explore RGB color control and how to manipulate the built-in RGB LED on your S3 Mini Pro ESP32.

Step 4: Draw a Circle With Text - or Image

The Draw a Circle sketch for the S3 Mini Pro ESP32 with a TFT display demonstrates how to use the Adafruit GFX library to draw a simple geometric shape—a circle—on the screen. This sketch shows how to set up the display, define coordinates, and draw a circle using the built-in graphics functions of the library.

How It Works:

  1. Library Setup:
  2. The sketch begins by including the necessary libraries: Adafruit_GFX (for graphics functions) and Adafruit_ST7735 (for the specific TFT display you're using).
  3. Pin Definitions:
  4. TFT_CS, TFT_RST, TFT_DC, and TFT_BL represent the control pins for the TFT display. These are essential for communication between the microcontroller and the display.

Take a look at page 5 of the schematic to understand the TFT pinout.

  1. Display Initialization:
  2. Inside setup(), the display is initialized with tft.initR(INITR_BLACKTAB); which prepares the screen for drawing. The screen is then cleared with a black background using tft.fillScreen(ST77XX_BLACK);.
  3. Drawing the Circle:
  4. The circle is drawn using the tft.drawCircle() function. Here’s the breakdown:
  5. x_center: The x-coordinate of the circle's center, calculated as half the display width.
  6. y_center: The y-coordinate of the circle's center, slightly shifted upward by 10 pixels to leave room for the message at the bottom.
  7. radius: The radius of the circle, set to 30 pixels.
  8. ST77XX_WHITE: The color of the circle, set to white.
  9. Displaying a Message:
  10. The tft.setCursor() function is used to set the position where text will be printed. In this case, the text is placed near the bottom of the screen.
  11. The tft.print() function then prints the message "Circle drawn!" on the display.

Key Functions:

  1. tft.drawCircle(x_center, y_center, radius, color):
  2. This function draws a circle on the display. It takes the x and y coordinates of the center, the radius, and the color of the circle as arguments.
  3. tft.setCursor(x, y):
  4. Sets the position where text will appear on the screen.
  5. tft.print("Text"):
  6. Prints the specified text at the current cursor position.


#include <Adafruit_GFX.h>    // Core graphics library

#include <Adafruit_ST7735.h>  // Library for the ST7735 TFT screen

#include <SPI.h>


// Define the pins for your display (adjust these to your setup)

#define TFT_CS  35 // Chip select pin

#define TFT_RST  34 // Reset pin

#define TFT_DC  36 // Data/Command pin

#define TFT_BL  33 // Backlight pin (TFT_BL/IO33)


// Create an instance of the display

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);


void setup() {

 // Initialize the backlight pin

 pinMode(TFT_BL, OUTPUT);

 digitalWrite(TFT_BL, HIGH); // Turn on the backlight


 // Initialize the display

 tft.initR(INITR_BLACKTAB); // Specific initialization for the ST7735 screen

 tft.fillScreen(ST77XX_BLUE); // Clear the screen with black background

 

 // Set the circle's parameters

 int x_center = tft.width() / 2; // X center of the circle

 int y_center = (tft.height() / 2) - 10; // Y center of the circle, shifted up by 24 pixels (3 rows)

 int radius = 26;        // Radius of the circle

 

 // Set text color and size

 tft.setTextColor(ST77XX_WHITE);

 tft.setTextSize(2);


 // Draw a circle

 tft.drawCircle(x_center, y_center, radius, ST77XX_WHITE);

 

 // Optionally display a message on the screen

 tft.setCursor(0, 0);

 tft.print("A Circle! Bits4Bots");

}


void loop() {

 // The loop remains empty for this demo

}


Download the file to draw a circle on the screen or the Bits4BotsTM logo.

I used an images to byte array online converter (C++, Arduino) to generate my robot logo. The TFT screen is 128 x 128 pixels.

  1. https://mischianti.org/images-to-byte-array-online-converter-cpp-arduino/

Concept:

  1. This sketch demonstrates how to display basic shapes and text on a TFT screen. Drawing a circle is just one of the many graphics functions provided by the Adafruit GFX library, which also supports lines, rectangles, triangles, and more.

Conclusion:

The Draw a Circle sketch is a great introduction to using graphical displays with the S3 Mini Pro ESP32. It shows how to combine graphics and text to create interactive or informative outputs on a small screen, which can be extended for more complex applications like games, data visualization, or custom user interfaces.

Step 5: Conclusion

The three starter projects—Blink, BlinkRGB Built-in, and Draw a Circle—serve as a great introduction to the capabilities of the S3 Mini Pro ESP32. These projects demonstrate the microcontroller's versatility, ease of use, and compatibility with the Arduino IDE. With Blink, you get started with basic GPIO control, while BlinkRGB introduces you to the built-in RGB functionality, showcasing the microcontroller’s built-in features. Finally, Draw a Circle highlights its capability to interact with external peripherals, like a TFT display, for more complex graphical output.

Step 6: Catching Pumpkins Game

Falling Pumpkins Game: Rules and Gameplay

Objective:

The goal of the game is to catch falling pumpkins by pressing the correct button corresponding to the column where the pumpkin is falling. Each successful catch increases your score, while missing a pumpkin results in a game over.

Game Setup:

  1. Start Screen:
  2. The game begins with a title screen that displays "Catch the Pumpkin!" along with an image of a big pumpkin.
  3. After a brief delay, the game screen clears, and the player is taken to the gameplay screen.
  4. Gameplay Screen:
  5. The screen is divided into three vertical columns where pumpkins can fall:
  6. Column 0: Left
  7. Column 1: Center
  8. Column 2: Right
  9. Pumpkins fall from the top of the screen toward the bottom.

Game Rules:

  1. Falling Objects:
  2. A pumpkin randomly falls from the top of the screen at regular intervals (every 1 second).
  3. The pumpkin will fall in one of the three columns.
  4. Catching Pumpkins:
  5. Players need to press the corresponding button when the pumpkin reaches the bottom of the screen:
  6. Left Button (IO0): For pumpkins falling in Column 0 (left).
  7. Center Button (IO47): For pumpkins falling in Column 1 (center).
  8. Right Button (IO48): For pumpkins falling in Column 2 (right).
  9. If the player presses the correct button as the pumpkin reaches the bottom, they successfully catch the pumpkin, and their score increases by 1.
  10. Game Over:
  11. If a pumpkin reaches the bottom of the screen without being caught (i.e., the player presses the wrong button or fails to press any button), the game ends.
  12. A game over screen displays the message "Game Over!" along with the player's final score.

Scoring:

  1. The player earns 1 point for each pumpkin caught.
  2. The score is displayed on the game over screen, allowing players to see how well they did.

Strategy Tips:

  1. Anticipate the Fall: Pay close attention to where the pumpkin is falling and be ready to react quickly.
  2. Button Press Timing: Timing is crucial; press the button as the pumpkin approaches the bottom to maximize your chances of catching it.

Conclusion:

The Falling Pumpkins Game is a simple yet engaging game that tests players' reaction times and button-pressing accuracy. It provides a fun Halloween-themed experience, making it suitable for all ages. Enjoy catching as many pumpkins as you can! 🎃