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

  • I connected/disconnected the 5V ... your experimentation lacks some steps. – jsotola Apr 13 '18 at 20:07
  • Should i add the ground? – kaya Apr 16 '18 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? – jsotola Apr 17 '18 at 3:10
  • 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 ! – kaya Apr 17 '18 at 9:59
3

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?

  • So should I add ground to the external µc too?? – kaya Apr 16 '18 at 8:14
  • You mean connect the grounds of both MCUs together...? Erm.... yes? hackingmajenkoblog.wordpress.com/2016/12/06/… – Majenko Apr 16 '18 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. – kaya Apr 16 '18 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.