Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PWM analogWrite doesn't work when pinMode is called more than once #8106

Copy link
Copy link
Closed
@lvlerber

Description

@lvlerber
Issue body actions

Board

esp32 dev module

Device Description

devkit

Hardware Configuration

no

Version

v2.0.6

IDE Name

platformio

Operating System

w10

Flash frequency

40

PSRAM enabled

yes

Upload speed

115200

Description

pinMode(15,OUTPUT);
analogWrite(15,255);
pinMode(15,OUTPUT);
analogWrite(15,128);

With this code I expect the second analogWrite to generate a 50% value on pin 15.
However, the second pinMode instruction will set the value of the pin to 0 and every analogWrite after that will not work.
DigitalWrite will work.

Sketch

#include <Arduino.h>

void setup() {
  // put your setup code here, to run once:
  pinMode(15,OUTPUT);
  analogWrite(15,255);
  delay(5000);
    pinMode(15,OUTPUT);
      delay(5000);
  analogWrite(15,255);

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(100);
}

Debug Message

na

Other Steps to Reproduce

na

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

Labels

Type

No type

Projects

Status

Done
Show more project fields

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.