PLX-DAQ Troubles

Hello Everyone, I have some programming background but not much with microcontrollers and wanted to try this out. The idea is using 10 push buttons as inputs. 5 Yes and 5 no answers. People will have the chance to enter yes or no using 1 of the 10 switches for 5 different questions. I want to take these answers and feed them live using an Excel document using PLX-DAQ. I'm just having issues with code and implementing the Excel add in. Please any help would be useful!

My code is below.

int x = 0;
int row = 0;

int yesDoorOnePin = 2; //sets Door one yes to pin 2 on arduino.
int noDoorOnePin = 3; //sets Door one no to pin 3 on arduino.
int yesDoorTwoPin = 4; //sets Door two yes to pin 4 on arduino.
int noDoorTwoPin = 5; //sets Door two no to pin 5 on arduino.
int yesDoorThreePin = 6; //sets Door three yes to pin 6 on arduino.
int noDoorThreePin = 7;//sets Door three no to pin 7 on arduino.
int yesDoorFourPin = 8; //sets Door four yes to pin 8 on arduino.
int noDoorFourPin = 9; //sets Door four no to pin 9 on arduino.
int yesDoorFivePin = 10; //sets Door five yes to pin 10 on arduino.
int noDoorFivePin = 11; //sets Door five no to pin 11 on arduino.


byte yesDoorOneState = 0; //Sets state to zero, has not been pushed.
byte noDoorOneState = 0;
byte yesDoorTwoState = 0;
byte noDoorTwoState = 0;
byte yesDoorThreeState = 0;
byte noDoorThreeState = 0;
byte yesDoorFourState = 0;
byte noDoorFourState = 0;
byte yesDoorFiveState = 0;
byte noDoorFiveState = 0;

byte yesFirstButtonCounter = 1; //Counts how many times button is pressed.
byte noFirstButtonCounter = 0;
byte yesTwoButtonCounter = 0;
byte noTwoButtonCounter = 0;
byte yesThreeButtonCounter = 0;
byte noThreeButtonCounter = 0;
byte yesFourButtonCounter = 0;
byte noFourButtonCounter = 0;
byte yesFiveButtonCounter = 0;
byte noFiveButtonCounter = 0;

void setup() {

  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  Serial.println("CLEARDATA");
  Serial.println("LABEL, TIME, FirstDoorYes, First Door No, Second Door Yes, Second Door No, Third Door Yes, Third Door No, Fourth Door Yes, Fourth Door No, Fifth Door Yes, Fifth Door No");


  pinMode(yesDoorOnePin, INPUT); // intializes the first yes doorbell as input
  pinMode(noDoorOnePin, INPUT); // intializes the first no doorbell as input
  pinMode(yesDoorTwoPin, INPUT); // initializes the second yes doorbell as input
 /* pinMode(noDoorTwoPin, INPUT); // intializes the second no doorbell as input
  pinMode(yesDoorThreePin, INPUT); // intializes the third yes doorbell as input
  pinMode(noDoorThreePin, INPUT); // intializes the first yes doorbell as input
  pinMode(yesDoorFourPin, INPUT); // intializes the first no doorbell as input
  pinMode(noDoorFourPin, INPUT); // initializes the second yes doorbell as input
  pinMode(noDoorFivePin, INPUT); // intializes the second no doorbell as input
  pinMode(yesDoorFivePin, INPUT); // intializes the third yes doorbell as input
*/
}

void loop() {


  //Serial.println("DATA, TIME"); 
 
  yesDoorOneState = digitalRead(yesDoorOnePin); // Reads the state of yes switch for door one.
  noDoorOneState = digitalRead (noDoorOnePin); // Reads the state of no switch for door one.
  yesDoorTwoState = digitalRead(yesDoorTwoPin); // Reads the state of yes switch for door two.
  
 /* 
  noDoorTwoState = digitalRead (noDoorTwoPin); // Reads the state of no switch for door two.
  yesDoorThreeState = digitalRead(yesDoorThreePin); // Reads the state of yes switch for door three.
  noDoorThreeState = digitalRead (noDoorThreePin); // Reads the state of no switch for door three.
  yesDoorFourState = digitalRead(yesDoorFourPin); // Reads the state of yes switch for door four.
  noDoorFourState = digitalRead (noDoorFourPin); // Reads the state of no switch for door four.
  yesDoorFiveState = digitalRead(yesDoorFivePin); // Reads the state of yes switch for door five.
  noDoorFiveState = digitalRead (noDoorFivePin); // Reads the state of no switch for door five.
*/

  if (yesDoorOneState == HIGH) // If door one is pressed yes then...
  {
    
    Serial.println(yesFirstButtonCounter);
    Serial.println("FirstButtonYes");
    Serial.println(",");
    yesFirstButtonCounter ++; //Adds 1
    delay(1000);
  }
  if (noDoorOneState == HIGH) // If door no is pressed yes then...
  {
    Serial.println(noFirstButtonCounter); //Prints Value to excel sheet
    Serial.println("FirstButtonNo");
    Serial.println(",");
    noFirstButtonCounter ++; //Adds 1
    delay(1000);
  }
   if (yesDoorTwoState == HIGH) // If door one is pressed yes then...
  {
    
    Serial.print(yesTwoButtonCounter); //Prints Value to Excel Sheet
    Serial.print("TwoButtonYes");
    Serial.print (",");
    yesTwoButtonCounter ++; //Adds 1
    delay(1000);
  }
 /* 
   if (noDoorTwoState == HIGH) // If door no is pressed yes then...
  {
    noTwoButtonCounter ++; //Adds 1
    Serial.print(noTwoButtonCounter); //Prints Value to excel sheet
    Serial.print("NOtwo"); //Temp
    delay(1000);
  }

   if (yesDoorThreeState == HIGH) // If door one is pressed yes then...
  {
    yesThreeButtonCounter ++; //Adds 1
    Serial.print ("Balls");
    Serial.print(yesThreeButtonCounter); //Prints Value to Excel Sheet
    Serial.print("YESthree"); // temp
    delay(1000);
  }*/
  /* 
  if (noDoorThreeState == HIGH) // If door no is pressed yes then...
  {
    noThreeButtonCounter ++; //Adds 1
    Serial.print(noThreeButtonCounter); //Prints Value to excel sheet
    Serial.print("NOthree"); //Temp
    delay(1000);
  }
  if (yesDoorFourState == HIGH) // If door one is pressed yes then...
  {
    yesFourButtonCounter ++; //Adds 1
    Serial.print(yesFourButtonCounter); //Prints Value to Excel Sheet
    Serial.print("YESfour"); // temp
    delay(1000);
  }
   if (noDoorFourState == HIGH) // If door no is pressed yes then...
  {
    noFourButtonCounter ++; //Adds 1
    Serial.print(noFourButtonCounter); //Prints Value to excel sheet
    delay(1000);

  }
  if (yesDoorFiveState == HIGH) // If door one is pressed yes then...
  {
    yesFiveButtonCounter ++; //Adds 1
    Serial.print(yesFiveButtonCounter); //Prints Value to Excel Sheet
    delay(1000);
  }
   if (noDoorFiveState == HIGH) // If door no is pressed yes then...
  {
    noFiveButtonCounter ++; //Adds 1
    Serial.print(noFiveButtonCounter); //Prints Value to excel sheet
    delay(1000);
    //}*/

  }

PERC.ino (5.81 KB)

Please edit your post and add code tags.
To get help, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.

What's not working?

Variables 0-255 can be type "byte".
Also, you may need INPUT_PULLUP in your pinModes

LarryD:
Please edit your post and add code tags.
To get help, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.

What's not working?

Hoping that helped. So everytime I try using the PLX-DAQ with this code nothing is being added to the excel file whenever I push a button. It seems to register it however. So I'm thinking its maybe something to do with my if statements or how I treat each pushbutton? I've been staring at this for hours but can't seem to make sense of it.

When you run the sketch with just the serial monitor, do things respond properly?

How are your switches wired?

Sleep time here. :sleeping:

Things seem to work perfectly in the serial monitor, each switch acts as its own and adds each time it is pressed more than once. Switches are wired with a pull down resistor to ground, one terminal to 5V and the other to its input on the arduino.

dcandido:
Things seem to work perfectly in the serial monitor,

So what version of Excel are you using?

Nick_Pyner:
So what version of Excel are you using?

I am using Excel 2013. I've tried taking sample code off the internet and it seems to work fine with the plug in

it seems to work fine with the plug in

So, you don't have a problem?

PaulS:
So, you don't have a problem?

No I do, it works in Serial Remote but when I try to start collecting data using my switches as inputs I receive nothing. However, when I turn on a pushbutton, the time feature will stop and it says its collecting data in the PLX-DAQ Excel but no values show up. Is there a specific value I need to add to my code in order to have data come up on the Excel?

PaulS:
So, you don't have a problem?

When I use code off the internet it works fine with the PLX-DAQ which leads me to believe its something in my code. I'm extremely new to arduino so I must be doing something incorrect with my inputs and how I'm reading this information using the arduino. I just can't seem to understand whats going wrong. Did I program my switches incorrectly? What can I do to display values onto the excel?

I just can't seem to understand whats going wrong.

You won't get useful help from the forum until you post your complete code, using code tags, and also an example of the serial output of the program.

Please edit your original post, rather than posting the code again.

I repeat:

You won't get useful help from the forum until you post your complete code, using code tags, and also an example of the serial output of the program.

Please delete the last post and edit your first post.

What can I do to display values onto the excel?

The reason that we ask about the version of Excel is because the PLX-DAQ plugin does not work with all versions of Excel. In particular, it does not work with the 2010+ versions.

PaulS:
The reason that we ask about the version of Excel is because the PLX-DAQ plugin does not work with all versions of Excel. In particular, it does not work with the 2010+ versions.

Wonderful, I have no access to older Excel software. Is there any other software that you know of that could potentially collect data in real time?

Is there any other software that you know of that could potentially collect data in real time?

Plenty of choices, depending on whether collect means "save to a file" or "show in some kind of viewer (and save to a file)".

PaulS:
The reason that we ask about the version of Excel is because the PLX-DAQ plugin does not work with all versions of Excel. In particular, it does not work with the 2010+ versions.

So I found an 2003 Excel download online. But I'm still having issues which leads me to believe it has to be something with my code. I'm still having the issue of it not populating data onto the Excel file.

All the PLX-DAQ examples I've seen indicate that you need to send some commands that PLX-DAQ understands, so it knows where to put the data in the Excel file. I don't see you doing that.

A very clear example of using PLX-DAQ is here: Arduino and real time charts in Excel « Robottini

Thank you for all of your help, I figured it out, it had to do with the placement of my Serial.print and Serial.prinln.