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
  • balajivan1995
    0 balajivan1995 2 days ago
    MikeK-LBC said:
    the voice uses the strips to display the voice in a fluid centre out visual like Kitt

    I have no idea what a "Kitt" means.
    But try these changes.

    // updated
    int halfLevel = 0;
    if(level%2==0)
    {
        halfLevel=(level+1)/2;
    }
    else
    {
        halfLevel=level/2;
    }
    for (int i = (center-halfLevel); i < (center+halfLevel); i++)
    {
        leds1[i] = COLOR;
        leds2[i] = COLOR;
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • cstanton
    0 cstanton 2 days ago in reply to balajivan1995
    balajivan1995 said:
    I have no idea what a "Kitt" means.

     Build a Larson Scanner with Sound Using an ESP32 -- Episode 670  

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • MikeK-LBC
    0 MikeK-LBC 2 days ago in reply to cstanton

    Knight Industries Two Thousand as in KITT from Knight Rider Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • MikeK-LBC
    0 MikeK-LBC 2 days ago in reply to cstanton

    Knight Industries Two Thousand as in KITT from Knight Rider Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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