Skip to content

Butterfly analogWrite and pinMode conflicts #48

Open
@jacky4566

Description

@jacky4566

There seems to be a problem with calling pinMode multiple times and using analogWrite.
The following code will fail for me:

static const int MOSFET = 9;

void setup() {
  //ON
  pinMode(MOSFET, OUTPUT);
  analogWrite(MOSFET, 255);
  delay(1000);
  //OFF
  analogWrite(MOSFET, 0);
  delay(3000);
  //ON
  pinMode(MOSFET, OUTPUT);//This pinMode causes problems
  analogWrite(MOSFET, 255);
  delay(1000);
  //OFF
  analogWrite(MOSFET, 0);
  pinMode(MOSFET, INPUT);
}

void loop() {
  delay(1);
}

Quite a few of the Arduino universe libraries use this format so its a bit frustrating to change them all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions