Input pin is always HIGH

Hi. I have done a few arduino projects before. Currently, I'm working on a project where I have to receive input signals on Arduino Nano from two RF receiver modules and an NRF24l01 module. I have made common ground for all these modules, as well as the power supplies. Signal from NRF24l01 works fine. But, input pins from the RF receivers appear to be HIGH always. I have checked the RF receiver modules separately and they work fine. What could be the problem here?

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10

#define RemoteOpen 2       //Remote Open on 2
#define RemoteClose 3      //Remote Close on 3
#define OpenLeft A0        //Open Left on A0
#define OpenRight A1       //Open Right on A1
#define OpenBoth A2        //Open Both on A2
#define CloseBoth A3       //Close Both on A3

#define Command1 4    //Command1 OpenLeft
#define Command2 5    //Command2 OpenRight 
#define Command3 6    //Command3 OpenBoth
#define Command4 7    //Command4 CloseBoth
  
int command = "";   //Buffer to recieve command
 
const uint64_t pipe = 0xE8E8F0F0E1LL;      // Pipe listens to Car

RF24 radio(CE_PIN, CSN_PIN);
 
void setup(){
 Serial.begin(9600);
 radio.begin();
 Serial.println("Starting...");
 radio.openReadingPipe(1,pipe);
 radio.startListening();
 delay(50);

 digitalWrite(LED_BUILTIN,LOW);

 pinMode(2,INPUT);
 pinMode(3,INPUT);
 pinMode(A0,INPUT);
 pinMode(A1,INPUT);
 pinMode(A2,INPUT);
 pinMode(A3,INPUT);

 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
}

void loop(){

  if(digitalRead(RemoteOpen)){
   Serial.println("A"); 
   digitalWrite(Command3,HIGH);
   delay(300);
   digitalWrite(Command3,LOW);
  }
    
  else if(digitalRead(RemoteClose)){
    Serial.println("Close");
    digitalWrite(Command4,HIGH);
    delay(300);
    digitalWrite(Command4,LOW);
  }

  else if(digitalRead(OpenLeft)){
    Serial.println("OpenLeft");
    digitalWrite(Command1,HIGH);
    delay(300);
    digitalWrite(Command1,LOW);
  }

   else if(digitalRead(OpenRight)){
    Serial.println("OpenRight");
    digitalWrite(Command2,HIGH);
    delay(300);
    digitalWrite(Command2,LOW);
  }
  
   else if(digitalRead(OpenBoth)){
    Serial.println("Open");
    digitalWrite(Command3,HIGH);
    delay(300);
    digitalWrite(Command3,LOW);
  }

  else if(digitalRead(CloseBoth)){
    Serial.println("Close");
    digitalWrite(Command4,HIGH);
    delay(300);
    digitalWrite(Command4,LOW);
  }
 
  else if ( radio.available() ){
    bool done = false;
    while(!done){
      done = radio.read(&command, sizeof(command) );
      Serial.println(command);
    }

    if(command == 3){
      Serial.println("Success");
      digitalWrite(Command3,HIGH);
      delay(300);
      digitalWrite(Command3,LOW);
    }
  }

 
}

First off:
Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

You may have a open collector/drain problem.
Use:
pinMode(pin,INPUT_PULLUP);

1 Like

Thanks. I think my problem was floating pin. Using INPUT_PULLUP solved the issue.

Well, if it solved the problem, OK, but INPUT_PULLUP makes an otherwise uncontrolled input, HIGH, so something is wrong with the description there! :astonished:

3 Likes

Input_pullup solved the problem only momentarily. The problem has started again after some time

Are you sure that these RF receiver modules are active HIGH ?
If these are active LOW, you need both INPUT_PULLUP and you need to invert your test, for example:
if( digitalRead(RemoteOpen) == LOW ) . . .

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.