Skip to content

Analogwrite to RGB LED on Nano ESP32 does not turn off completely #10534

@ednieuw

Description

@ednieuw

Board

Arduino Nano ESP32

Device Description

Arduino Nano ESP32

Hardware Configuration

No

Version

latest development Release Candidate (RC-X)

IDE Name

Arduino IDE 1.0 and 2.0

Operating System

Windows 11

Flash frequency

NA

PSRAM enabled

yes

Upload speed

NB Arduino settings in board

Description

The RGB LED keeps on faintly when it should be off when writing 512 to the analog port of the LED_RED, LED_GREEN or LED_BLUE

When writing 513 the LED colour turns off.
So there is an one bit discrepantie

Sketch

int Toggle=0;
void setup() {}
void loop() 
{
 UpdateStatusLEDs(Toggle);
 Toggle = 1 - Toggle;
 delay (1000);
}

//--------------------------------------------                                                //
// COMMON Update routine for the status LEDs
//-------------------------------------------- 
void UpdateStatusLEDs(int Toggle)
{
 if(Toggle)   
   {
    SetStatusLED(Toggle * random(100), Toggle * random(100), Toggle * random(100)); 
    analogWrite(48,  Toggle * 50);     
   }
   else
   {
    SetStatusLED(0,0,0); 
    analogWrite(48, 0);                                                               // on Nano ESP32 Turn the LED off    
   }
}
//--------------------------------------------
// COMMON Control the RGB LED on the Nano ESP32
// Analog range 0 - 512. 0 is LED On max intensity
// 512 is LED off. Therefore the value is subtracted from 512 
//--------------------------------------------
void SetStatusLED(int Red, int Green, int Blue)
{
 analogWrite(LED_RED,   512 - Red);                                                            // !Red (not Red) because 1 or HIGH is LED off
 analogWrite(LED_GREEN, 513 - Green);
 analogWrite(LED_BLUE,  513 - Blue);
}

Debug Message

none

Other Steps to Reproduce

With the Arduino Nano ESP32 core 2.0.18 the RGB turns off completely.
When using core 3.0.5 up to the latest core 3.1.0 RC2 this occurs.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Community help neededIssue need help from any member from the Community.Type: 3rd party BoardsRelated to third-party/non-Espressif hardware boards.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions