Pages: [1]   Go Down
Author Topic: Arduino Due digitalread is always I  (Read 542 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

Hey
I think i have got a problem with my due and i dont know why. I was trying to run the digitalread example. But in any case, even if there is not any connection to my digitial I/O pins, the state is 1.
Of course i have used 3.3V since its a due. Iam quite a noob so be kind please.

mfg Oklox
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34220
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But in any case, even if there is not any connection to my digitial I/O pins, the state is 1.
You should never leave an input unconnected it can show anything. Try connecting it to ground and then read it.
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
Logged

White River Junction, Vermont USA
Offline Offline
Full Member
***
Karma: 5
Posts: 106
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To expand on Grumpy_Mike's response, I would suggest that while testing, you connect any digital-inputs to ground through a resistor. 

The resistor should be no less than 1100 Ohms.  This protects the pin on the SAM chip in case the pin that you are connecting is inadvertently programmed as an OUTPUT and you connect it to ground (mistakes do happen).  Do note that DIO pins default to INPUT at power-up, and they must be programmed as OUTPUT in code. 

However, the good old resistor will still prevent sparks when you accidentally ground the power supply pins, instead of the intended DIO pins.  Not that I've ever done that :-/

I keep some pre-soldered resistors with leads handy for this type of thing.

Possible exception: Arduino Pins 20 & 21 (SAM Ports B.12 & B.13), which are pulled-UP on the Arduino PCB with 1000 ohms to 3.3V.  Using a 1100-Ohm pull-DOWN on these pins may give unreliable results (these are designated as I2C pins).  However, nothing will be harmed.

Why 1100-Ohms?: The 'weakest' pins on the SAM chip are spec'd to be able to source 0.003Amps maximum.  3.3V / 0.003A = 1100 (Ohms).
(I am using 3.3V here as a worse-case number, the actual voltage output by a digital-output pin will be a bit less)

Good luck,

-Chris
Logged

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

Thank you!

Really helped me out
Logged

Pages: [1]   Go Up
Jump to: