Pages: [1]   Go Down
Author Topic: Problem getting state and toggling output pin on Arduino Due  (Read 776 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I have got a problem with toggling and getting current state of the output pin on Arduino Due and Arduino 1.5.2 software.
The pin stays high all the time and digitalRead(pinnum) always returns 0.
Tried with this code and some variations of it.

Code:
int pinnum = 13;
void setup() {
  pinMode(pinnum, OUTPUT);  // use on-board LED
}

void loop() {
  digitalWrite(pinnum, !digitalRead(pinnum));
  delay(1000);  // wait around for 1 sec (1000 ms)
}

I would appreciate help very much.
« Last Edit: February 26, 2013, 08:34:11 pm by Euhenio » Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11159
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have got a problem

What is the problem?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the problem?

The pin stays high all the time and digitalRead(pinnum) always returns 0. The code I've posted earlier doesn't blink led.
Sorry, forgot to describe the problem in first post. Edited.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the Due, possibly reading an output pin may always return 0. After all, reading from output is not necessarily defined.

I'm moving this to the Due section of the forum.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the Due, possibly reading an output pin may always return 0. After all, reading from output is not necessarily defined.

I'm moving this to the Due section of the forum.

Is there any work around for this? Or determining current state of output pin is not really possible on Due?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Make your own function, that when you do a digitalWrite, it remembers what you set it to.

I personally think, that when you set something as "output" it isn't all that valid to read from it. It's your job to remember what you last wrote.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Make your own function, that when you do a digitalWrite, it remembers what you set it to.

I personally think, that when you set something as "output" it isn't all that valid to read from it. It's your job to remember what you last wrote.

Ok, I got the idea. Thanks for help.
Logged

Pages: [1]   Go Up
Jump to: