0

I work with Arduino DUE. I would like to configure few of my digital pins as INPUT pins. When the μc sets these particular 4 pins , the DUE must be activated. Something like a DATAREADY pin in the SPI,where the data will be sent to the slave only,when it sets the pin to 1.

According to the datasheet , the external μC would set the pin state from 0 to 1. I tried this program for experimenting the effect of digital pins,

int RDY = 52;
void setup() {
 Serial.begin(9600); 
pinMode(RDY,INPUT_PULLUP);
pinMode(50,INPUT);
digitalWrite(RDY,HIGH);
}
void loop() {
digitalRead(RDY);
digitalRead(50);
digitalRead(11);
digitalRead(12);
Serial.println(digitalRead(RDY));
Serial.println(digitalRead(50));
Serial.println(digitalRead(11));
Serial.println(digitalRead(12));
delay(100);
}

Results obtained are; 1,1,0,0 as expected. I cannot find a proper way to detect the change of state of the pin (from 0 to 1). To make detect changes, I connected/disconnected the 5V output pin of DUE to the particular digital pins. The results never changed with connection and disconnection of the 5V wire for any pin.

Is there any possible way to detect the change of the pin state as in INPUT mode in Arduino DUE? Most examples are dealing with switches,but in my case I need a pin as a input.

Thanks

asked Apr 13, 2018 at 18:37
5
  • I connected/disconnected the 5V ... your experimentation lacks some steps. Commented Apr 13, 2018 at 20:07
  • Should i add the ground? Commented Apr 16, 2018 at 8:13
  • if you are doing "experiments" by applying a logic 1 (+5V), why did you not apply a logic 0 (gnd)? .... if you were a biologist that is studying how frogs react to coloured light, would you use blue light only? Commented Apr 17, 2018 at 3:10
  • electronics-tutorials.ws/logic/pull-up-resistor.html Commented Apr 17, 2018 at 3:11
  • pinMode(50,INPUT); digitalWrite(RDY,HIGH); with this I tried pinMode(50,INPUT); digitalWrite(RDY,LOW); Then later I realised ,that Input will always only stay high(becoz of oull-ups) , as writing LOW on the input is not affected. I realised I had messed it ! Commented Apr 17, 2018 at 9:59

1 Answer 1

4

There is no difference between a switch and a "pin" for input. All are either HIGH or LOW. You tie it HIGH with the pullup, and then try giving it a HIGH with +5V (Caution: The Due is a 3.3V device, not 5V!).

At no point do you ever give it a LOW signal (connect the input to GND), so how can it ever read LOW?

answered Apr 13, 2018 at 18:47
3
  • So should I add ground to the external µc too?? Commented Apr 16, 2018 at 8:14
  • You mean connect the grounds of both MCUs together...? Erm.... yes? hackingmajenkoblog.wordpress.com/2016/12/06/… Commented Apr 16, 2018 at 8:14
  • Oh that link was excellent,and I was silly ! So for experiment , I connected the pin 52 with GND from the DUE board. It read 0 when connected. I will connect the DUE's GND with the external µc's GND , for the actual program. Commented Apr 16, 2018 at 8:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.