Reputation: 52
I want to do something very basic as shown below:
#define READ_PIN 7
#define WRITE_PIN 8
void setup() {
pinMode(READ_PIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
digitalWrite(WRITE_PIN, LOW);
Serial.println(digitalRead(READ_PIN));
}
I am bridging the WRITE_PIN and READ_PIN together to read what the pin is outputting.
The input always reads '1' as expected with INPUT_PULLUP, but I would like it to read '0'. I get the same results using analogRead()
and analogWrite()
, no matter which pins I use.
Does anybody know why this seems impossible to achieve?
Upvotes: 0
Views: 588
Reputation: 126857
(moving from the comment)
Pin mode on Arduino is set to INPUT
by default1; to use WRITE_PIN
as an output you have to explicitly set it as such in setup
.
pinMode(WRITE_PIN, OUTPUT);
Upvotes: 1