element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experts, Learning and Guidance
  • Technologies
  • More
Experts, Learning and Guidance
Ask an Expert Forum Could anyone help? with esp32 s3?
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experts, Learning and Guidance to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 8 replies
  • Subscribers 290 subscribers
  • Views 147 views
  • Users 0 members are here
Related
See a helpful answer?

Be sure to click 'more' and select 'suggest as answer'!

If you're the thread creator, be sure to click 'more' then 'Verify as Answer'!

Could anyone help? with esp32 s3?

MikeK-LBC
MikeK-LBC 2 days ago

I was hoping to get to a car meet tomorrow and while my pi 5 and ai are being built i am adding an s3 dev kit to my front voice visual kit but i cant seem to get the code to play nice. 

So it is done like this. 

I have 4 x 85cm led strips horizontal on the crash bar, these have level shifters at the strips and the strips are powered by their own buck (all earths are local)

I want the s3 to do 2 things... 

When my pir sensors are triggered and the voice starts, the voice uses the strips to display the voice in a fluid centre out visual like Kitt and then when the voice stops playing an idle scan kicks in for 3 min scanning from centre out. 
If the pir is triggered again the s3 will cut in and allow the voice to use the led strips and then when finished it drops back to idle scan and 3 min timer starts again. If it is not triggered withing 3 min the led strips turn off and the system awaits the voice being triggered again and this whole process restarts. 

I have a version that works, the voice triggers but it comes out from the left and not centre out. Then when the voice ends the idle scan kicks in and if voice is triggered it cuts back in but again from the left. 

SO it is basically there it just has 2 problems

1. the voice bit needs changing to centre out. 

2. When you take power off and re attach power the whole things changes and is no longer the same, something to do with the leds receiving signal before the s3 has booted or something.

I use Ai to help me code but it has me spinning in circles at min. If i ask it to fix the code it changes it completely. 

Can anyone here help me sort the code so that it works?

Any help would be greatly appreciated. 

This is the code...

#include <FastLED.h>

#define LED_PIN1 6 // LED Pair 1
#define LED_PIN2 7 // LED Pair 2
#define NUM_LEDS 51 // LEDs per pair
#define BRIGHTNESS 150
#define COLOR CRGB::Red

#define STROBE_PIN 8 // MSGEQ7 STROBE
#define RESET_PIN 4 // MSGEQ7 RESET
#define AUDIO_PIN 3 // MSGEQ7 OUT (ADC)
#define IDLE_TIMEOUT 180000 // 3 min in ms

CRGB leds1[NUM_LEDS];
CRGB leds2[NUM_LEDS];

unsigned long lastActivityTime = 0;
bool idleActive = false; // start idle OFF
int trailLength = 5;
int center = NUM_LEDS / 2;
int step = 0;
int direction = 1;

void setup() {
FastLED.addLeds<WS2812, LED_PIN1, GRB>(leds1, NUM_LEDS);
FastLED.addLeds<WS2812, LED_PIN2, GRB>(leds2, NUM_LEDS);
FastLED.clear();
FastLED.show();

pinMode(STROBE_PIN, OUTPUT);
pinMode(RESET_PIN, OUTPUT);
pinMode(AUDIO_PIN, INPUT);

lastActivityTime = millis();
}

void loop() {
int audioValue = analogRead(AUDIO_PIN); // 0-4095 on S3
bool triggered = audioValue > 1200; // adjust threshold for your audio

if (triggered) {
// Voice triggered mode
idleActive = false;
lastActivityTime = millis();

// Example: simple red bar proportional to audio
int level = map(audioValue, 0, 4095, 0, NUM_LEDS);
FastLED.clear();
for (int i = 0; i < level; i++) {
leds1[i] = COLOR;
leds2[i] = COLOR;
}
FastLED.show();
} else {
// Idle scan
if (!idleActive) {
idleActive = true;
lastActivityTime = millis();
step = 0;
direction = 1;
}

FastLED.clear();

// Mirrored trail
for (int i = 0; i < trailLength; i++) {
int outPos = step - i * direction;
int leftPos = center - outPos;
int rightPos = center + outPos;
if (leftPos >= 0 && leftPos < NUM_LEDS) {
leds1[leftPos] = COLOR;
leds2[leftPos] = COLOR;
}
if (rightPos >= 0 && rightPos < NUM_LEDS) {
leds1[rightPos] = COLOR;
leds2[rightPos] = COLOR;
}

if (i > 0) {
if (leftPos >= 0 && leftPos < NUM_LEDS) {
leds1[leftPos].fadeToBlackBy(i * 50);
leds2[leftPos].fadeToBlackBy(i * 50);
}
if (rightPos >= 0 && rightPos < NUM_LEDS) {
leds1[rightPos].fadeToBlackBy(i * 50);
leds2[rightPos].fadeToBlackBy(i * 50);
}
}
}

FastLED.show();
step += direction;
if (step <= 0 || step >= center) direction *= -1;
}

// Reset idle timer
if (idleActive && (millis() - lastActivityTime > IDLE_TIMEOUT)) {
FastLED.clear();
FastLED.show();
lastActivityTime = millis(); // restart idle scan
}

delay(30); // adjust speed
}

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz 1 day ago in reply to beacon_dave +2
    I noticed that when balajivan1995 interpreted it correctly, however I felt it best to leave what I'd written, since it also demonstrates how it's easy to mislead with the word 'it'; we only have finite…
  • beacon_dave
    beacon_dave 1 day ago in reply to shabaz +1
    Hi Shabaz, I think you have misinterpreted the post here. I think this is more about switching between two LED animations not panning the audio. In voice mode the LEDs should animate from centre…
Parents
  • shabaz
    0 shabaz 2 days ago

    Hi,

    Left vs center voice has nothing to do with the code (the code doesn't generate sound, nor does it interface to more than one signal input).

    If sound is only emanating from the left side, you've not shared the circuit nor code that is responsible for sound generation and connection to you audio system, or if sound is only detected from the left side, then your ADC input connection needs to be examined (there is no circuit or wiring diagram).

    Regarding the second issue, I don't know the issue, but it would be very sensible to insert a short delay in your setup function (at the start of the function), such as delay(100); before any of the FastLED commands in that function, so that there is time for circuitry to settle before signals are sent from your setup function.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • shabaz
    0 shabaz 2 days ago

    Hi,

    Left vs center voice has nothing to do with the code (the code doesn't generate sound, nor does it interface to more than one signal input).

    If sound is only emanating from the left side, you've not shared the circuit nor code that is responsible for sound generation and connection to you audio system, or if sound is only detected from the left side, then your ADC input connection needs to be examined (there is no circuit or wiring diagram).

    Regarding the second issue, I don't know the issue, but it would be very sensible to insert a short delay in your setup function (at the start of the function), such as delay(100); before any of the FastLED commands in that function, so that there is time for circuitry to settle before signals are sent from your setup function.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • beacon_dave
    0 beacon_dave 1 day ago in reply to shabaz

    Hi Shabaz,

    I think you have misinterpreted the post here.

    I think this is more about switching between two LED animations not panning the audio.

    In voice mode the LEDs should animate from centre out

    In scan mode the LEDs should animate left to right to left (Larson scanner).

    PIR triggers the voice mode so the LEDs should animate centre out.

    When voice completes playback the LEDs should do the Larson scanner effect for up to 3minutes.

    If PIR is triggered during the 3minute Larson scanner timeout, then the timeout should cancel and reset and the LEDs should animate centre out.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz 1 day ago in reply to beacon_dave

    I noticed that when balajivan1995 interpreted it correctly, however I felt it best to leave what I'd written, since it also demonstrates how it's easy to mislead with the word 'it'; we only have finite time to share, and people are unlikely to dedicate as much time a second time around.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • MikeK-LBC
    0 MikeK-LBC 1 day ago in reply to beacon_dave

    Hi, thanks so much for the reply

    This setup is almost exactly what I’m aiming for, the only thing missing is that the voice effect needs to run centre-out rather than from one side.

    Currently, everything activates perfectly: when powered, it plays one of the audio tracks as expected, but the LED animation starts from the left of the strips instead of from the centre. When the track finishes, the centre-out scan begins, and when the PIR sensor is triggered, the voice sketch plays again (still starting from the left). After that, it returns smoothly to the idle scan. So, the main issue I’m trying to solve is getting the voice animation to start from the centre, expanding outwards in a diamond-style pattern (I’ve upgraded to seven LED strips).

    I also suspect I need to introduce a delay somewhere, because after a power cycle the animation sequence changes entirely and doesn’t seem to follow the intended behaviour. It feels like the ESP32-S3 needs time to fully boot or clear any leftover data before running the LEDs. Ideally, the system doesn’t need to start immediately on power-up, it can wait until the first PIR trigger before beginning the sequence. That should ensure the S3 is fully initialised and prevent any conflicting LED data.

    The updated animation plan is:

    • All seven LED strips are used during voice playback. (diamond shape/centre out)

    • The middle three strips handle the idle scan. (centre out)

    Hardware setup:

    • Waveshare ESP32-S3 Development Board (with Headers), 16MB Flash

    • MSGEQ7

    • Level shifters for each LED strip

    • Power and ground are handled through bus bars and buck converters directly to the LEDs and circuits (no power is shared or looped through other circuits).

    This setup also need to be able to link to AI control, allowing the AI to trigger the voice display and speaker system. The AI will initially run on a Raspberry Pi 5 (16GB), with plans to add an AI accelerator later so it can operate more locally.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • beacon_dave
    0 beacon_dave 1 day ago in reply to MikeK-LBC
    MikeK-LBC said:
    This setup is almost exactly what I’m aiming for, the only thing missing is that the voice effect needs to run centre-out rather than from one side.

    I think I captured that bit here ?

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube