Apparent Pullup issue

Hello guys,

I just had fixed a problem on my project with the connections of an SPI peripheral and a LiquidCrystal display and then another problem appeared: Now it seems that all push buttons have a big pullup problem.
They keep in HIGH state all the time. I thought this could be a pullup matter, but even with the button pin connected to GND it's still in HIGH state!

Can you guys help me?

_20171015_Client_Tx_ver3.ino (3.82 KB)

I am going to guess that ISP (In System Programmable) was supposed to be SPI (Serial Peripheral Interconnect). However...

Even a newbie with six posts should know this:

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
    3) Paste the complete error message between code tags (the </> button)
    ~~ so that we can easily see and deal with your messages.~~
  3. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.
  4. Please provide links to any libraries that are used
    (look for statements in your code that look like #include ). Many libraries
    are named the same but have different contents.

Before posting again, you should read the three locked topics by Nick Gammon near the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!

thanks for the tips Vaj.

I am using two uno arduinos to communicate using nRF24L01. The transmitter code is the one I am having problems with. It has a LiquidCrystal, a nRF and 6 push buttons connected into it. Somehow I have some kind of bug that all the push buttons are all time HIGH and I have already checked if it's a matter of pullup resistors, but no apparent reasons for this bug so far....

Here is the transmitter code.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <LiquidCrystal.h>

#define CE_PIN  8
#define CSN_PIN 7
//===LCD===
LiquidCrystal lcd(10, 9, 5, 4, 3, 2);
//=== Botões de controle ====//
int b1 = A0; //"1"
int b2 = A1; //"2"
int b3 = A2; //"3"
int b4 = A3; //"4"
int b5 = A4;//delete
int b6 = A5;//Send
//=========  Logic =================
//int val[16]; //string containing the ordered numbers
int a = 0; // test variable
int i = 0; // array address
int x = 0;//state machine
//int any = (b1 || b2 || b3 || b4 || b5 || b6);
int orders[16]; // order array.
int len = 0; // Array length
int n = 0; //This will be the order array index


//=========  nRF =============
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int dataToSend[16]; //the 555 is the initialization code and 666 the end of code
void send();


void setup() {
  //===Serial ===
  Serial.begin(9600);
  Serial.println("ClientTx Starting");
  //=== nRF ==
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.setRetries(3, 5); // delay, count
  radio.openWritingPipe(slaveAddress);
  //=== Client ===
  pinMode(b1, INPUT); // inicializa botão
  pinMode(b2, INPUT);
  pinMode(b3, INPUT);
  pinMode(b4, INPUT);
  pinMode(b5, INPUT);
  pinMode(b6, INPUT);
  lcd.begin(16, 2);
  b1 = LOW;
  b2 = LOW;
  b3 = LOW;
  b4 = LOW;
  b5 = LOW;
  b6 = LOW;
  //    === LCD Set Screen ===
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Entre com pedidos:");
  lcd.setCursor(0, 1);

  // ==== TEST:Const array to be sent
  orders[0] = 1;
  orders[1] = 2;
  orders[2] = 3;
  orders[3] = 4;
  orders[4] = 5;
  orders[5] = 6;
  orders[6] = 7;
}



void loop() {


  //=== LCD Set Screen ===
  lcd.setCursor(0, 0);
  lcd.print("Entre com pedidos:");
  lcd.setCursor(0, 1);
  x = 1;

stateOne:
  while (x = 1) {  //machine state 1
    if (digitalRead(b1) == HIGH) {
      lcd.setCursor(i, 1);        //b1
      orders[i] = 1;
      lcd.print('1');
      i = i + 1;
    }
    if (digitalRead(b2) == HIGH) {
      lcd.setCursor(i, 1);        //b2
      orders[i] = 2;
      lcd.print('2');
      i = i + 1;
    }
    if (digitalRead(b3) == HIGH) {
      lcd.setCursor(i, 1);        //b3
      orders[i] = 3;
      lcd.print('3');
      i = i + 1;
    }
    if (digitalRead(b4) == HIGH) {
      lcd.setCursor(i, 1);        //b4
      orders[i] = 4;
      lcd.print('4');
      i = i + 1;
    }
    for (int l = 0; l < i; l = l + 1) {
      Serial.print(orders[l]);  // serial print values from orders array
      Serial.print(";");
      Serial.print("\n");
    }
    //for (int l = 0; l < i; l = l+1){Serial.write(l);} // TEST to get values from i
  }
  //===SEND ARRAY===
  a = digitalRead(b1);
  if (a == HIGH) {
    send(orders);

    delay(500);
    //}


  }



}

//====================

void send(int input[16]) {

  // getting max index of input array
  for (int i = 0; input[i] != 0; i++ ) {
    len = i + 1;
  }
  // writing the array dataToSend
  dataToSend[0] = 555; //begin of the message
  len = len + 1;
  for (int i = 1; i != len; i++) { //new max index is len +1 because of the begin of message
    dataToSend[i] = orders[i - 1];
    n = i;
  }
  //len = len +1;
  dataToSend[len] = 666; // end of the message //new max index is len +6 because of the end of message

  for (int i = 0; i <= len; i++) {
    radio.write( &dataToSend[i], sizeof(int)); //send values one by one
    Serial.print(dataToSend[i]);
    Serial.print(";");
    delay(100);
  }
  Serial.print("\n");
}

attached is the schematic of my project

while (x = 1) { //machine state 1 <==== Won't work the way you're expecting

There's a few other convoluted methods in there (read about strlen() among others.

attached is the schematic of my project

There is not enough detail in it to see how the buttons are wired. All it shows is lines connected between boxes labelled BUTTON and Arduino pins. How are the buttons actually wired ?

Have you considered using the built in pullup resistors by using INPUT_PULLUP in pinMode() so that external resistors are not required ?