I'm trying to read the PORTD using the PIND command, but always keep getting TX button blinking...
I thought the PIND command only read state of the PIN, and doesn't change the state of the PIN.
Why ?
const int SwPA = 2; // Switch at PORTD 2 .. Connected to LOW
const int SwMA = 3; // Switch at PORTD 2 .. Connected to LOW
int buttonPressed;
void setup(){
Serial.begin(9600);
pinMode(SwPA, INPUT);
pinMode(SwMA, INPUT); // Set as input
digitalWrite(SwPA, HIGH); // activate internal pull-up
digitalWrite(SwMA, HIGH); // activate internal pull-up
}
void loop(){
buttonPressed = PIND & B00001100; // Read only the Digital Pin 2 and 3
Serial.println(buttonPressed);
delay(1000);
}
Sugengz:
I'm trying to read the PORTD using the PIND command, but always keep getting TX button blinking...
I thought the PIND command only read state of the PIN, and doesn't change the state of the PIN.
Why ?
Sugengz:
I’m trying to read the PORTD using the PIND command, but always keep getting TX button blinking…
I thought the PIND command only read state of the PIN, and doesn’t change the state of the PIN.
Why ?
The Tx button (button?) - the one that lights up when you do a Serial.println?
Sugengz:
I'm trying to read the PORTD using the PIND command, but always keep getting TX button blinking...
I thought the PIND command only read state of the PIN, and doesn't change the state of the PIN.
Why ?
[quote author=Nick Gammon link=topic=78728.msg594392#msg594392 date=1321083616]
Try to get the terminology right. The thing that blinks is a LED, not a button.
Why aren't you using digitalRead? That is simpler to use and works over more platforms.
[/quote]
Yes, it's supposed TX Led, not a button (thanks for the correction) .
I'm trying to read the digital pin 2 until 7 as a binary combination, and read it all in a single line of instruction, not pin by pin. (this case I tried to do digital pin 2 and 3 only).
Can we use digitalRead to read digital pin 2 until 7 in a single line of instruction?