Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes analogWrite #8137

Merged
merged 3 commits into from
May 3, 2023
Merged

Fixes analogWrite #8137

merged 3 commits into from
May 3, 2023

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Apr 29, 2023

Description of Change

If analogWrite(pin, val) is called a second time after a pinMode(), it doesn't work.

Tests scenarios

Tested with ESP32

#define PWM_PIN 2

void setup() {
  pinMode(PWM_PIN, OUTPUT);
  analogWrite(PWM_PIN, 255);
  delay(2000);
  pinMode(PWM_PIN, INPUT);
  analogWrite(PWM_PIN, 64);
  delay(2000);
  pinMode(PWM_PIN, OUTPUT);
  analogWrite(PWM_PIN, 16);
  delay(2000);
  pinMode(PWM_PIN, OUTPUT); // it goes to Low as default
}

void loop() {
  delay(100);
}

Related links

Fixes #8106

@SuGlider SuGlider added the Area: Peripherals API Relates to peripheral's APIs. label Apr 29, 2023
@SuGlider SuGlider added this to the 2.0.9 milestone Apr 29, 2023
@SuGlider SuGlider self-assigned this Apr 29, 2023
Copy link
Collaborator

@mrengineer7777 mrengineer7777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@me-no-dev me-no-dev merged commit a7bd6c9 into master May 3, 2023
35 checks passed
@me-no-dev me-no-dev deleted the analogWrite-Fix branch May 3, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs.
Projects
Development

Successfully merging this pull request may close these issues.

PWM analogWrite doesn't work when pinMode is called more than once
4 participants