06-17-2018 10:51 AM - edited 06-17-2018 10:51 AM
I am working on tictactoe game played using an arduino and viewed in LabView.
Can i connect 3x3 button (Digital pins) to LED array on LabView?
06-17-2018 10:52 AM
Yes, of course.
06-17-2018 06:01 PM
Would you mind teaching me how to connect it? There's always an error whenever i try it,
06-17-2018 06:21 PM - edited 06-17-2018 06:22 PM
A sample would be this one (not my vi). I got this here:
How can i connect 3x3 push button (arduino digital pins) to the LED array?
06-17-2018 11:17 PM
Well, what kind of digital signal do you get from the push buttons? How are things connected? We really need much more information in order to help.
(If you have 9 digital inputs, you can just reshape them into a 3x3 2D array. )
On a side note, that VI is pretty bad, with blatant overuse of local variables. None are needed here. Also all subVIs are missing. (for some ideas, have a look at my old 4x4 tic tac toe that can play perfectly and knows the absolute best move for all possible positions. for 3x3, the problem is much simpler!)
06-18-2018 02:30 AM
Indeed, what kind of hardware do you have available? How are things connected?
Depending on the push button array, you might not even need the Arduino and connect it directly to a NI-DAQ or NI-USB if you have these available.
If you don't have these, or if the push buttons require a special library, I would say your best bet is to communicate between Arduino and LabVIEW via the serial connection. You can create your own string format to pass data around between the two.
06-18-2018 05:36 AM
"If you have 9 digital inputs, you can just reshape them into a 3x3 2D array."
How can i do this? (a sample vi would be much appreciated)
I have a tictactoe project using arduino and labview, it's suppose to be played using an arduino. The vi i showed which i got from here,
was only tictactoe game using labview. I want to play it using push buttons connected on arduino.
06-18-2018 06:01 AM - edited 06-18-2018 06:06 AM
What kind of hardware do you have (available)? Be a bit more specific please, so we know where to point you at.
As I understand your first post, your questions are: 1) how to detect which button is pressed (Arduino), and 2) how to get this information into LabVIEW.
The first one is a simple Arduino task. I assume you have a 3x3 keypad like this one. You can see from its documentation that it has six outputs: three for rows, three for columns. Ergo, you can make 2D coordinate like (row, column).
To send this data to LabVIEW, you can establish a serial connection. On your Arduino, you can format the input coordinates into a string (you can make up your own format here) and send this whenever a button is pressed. In your LabVIEW program, you can take these coordinates with the code you posted earlier.
06-18-2018 06:25 AM
Sorry for very little information.
Actually i only have tact switches, arduino (and LED).
My questions are: Can i use tact switches to create an array? And how? (or if i can't use tact switches, what can i use? (anything with button) )
Or how can i connect tact switches to the LED array in the labview program i send earlier?
For my project i need to create a labview program (tictactoe game) and play it using arduino. Thank you very much for your response.
06-18-2018 07:14 AM - edited 06-18-2018 07:17 AM
@clown1239 wrote:
Actually i only have tact switches, arduino (and LED).
My questions are: Can i use tact switches to create an array? And how? (or if i can't use tact switches, what can i use? (anything with button) )
Yes, you can use tact switches on your Arduino. In this case, I would just connect 9 switches to 9 inputs on the Arduino. Simply check which button was pushed. You can number the buttons, where each button simply indicates one point in your Tic-tac-toe grid:
1 2 3 4 5 6 7 8 9
There are tutorials on how to use (tact) switches with Arduino: https://www.arduino.cc/en/Tutorial/Button
This is actually the first question I mentioned in my previous post.
@clown1239 wrote:
Or how can i connect tact switches to the LED array in the labview program i send earlier?
See my previous post. Once you can identify which button was pushed on the Arduino, you can send this data from the Arduino to LabVIEW over a serial connection. In your LabVIEW, open a serial connection to the Arduino. Each time a button is pressed, have the Arduino send the button number over this connection. Whenever the LabVIEW program receives this number, use this as input for the further code you sent. National Instruments has tutorials on how to work with serial communication in LabVIEW: http://www.ni.com/tutorial/2897/en/
Please look into the individual steps you need to make, and ask specific questions about them. That helps us to help you with more precise answers.