Skip to content

the pin mode is changed to INPUT mode #28

Closed
@Makeblock-official

Description

@Makeblock-official

on file wiring.c line 87(Fun init()) Setup all pins (digital and analog) in INPUT mode (default is nothing)
Pin mode should not be set.This line should comment.

on file wiring_digital.c line 81 (Fun digitalWrite()) Enable pull-up resistor.
This line should comment.

The pin mode will be initialized when construct the object.

For example:

class LED
{
  public:
    LED(int pin);
    void low();
    void high();
  private:
    int led_pin;
};

LED::LED(int pin)
{
  led_pin = pin;
  pinMode(led_pin, OUTPUT) ;
}

void LED::low()
{
  digitalWrite(led_pin, LOW);
}
void LED::high()
{
  digitalWrite(led_pin, HIGH);
}

LED led(13);
void setup() {
}

void loop() {
  led.high();
  delay(1000);
  led.low();
  delay(1000);
}

Since the pin mode is changed to INPUT,led.high() is set to input pull-up and led.low() is set to input pull-down.So the led will be very dark.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions