New to Arduino, need help writing a program.

First things first, my name is Adam and I am a sophomore studying Electrical Engineering at SDSM&T. I am currently taking a Sophomore Design class and my group is trying to build a automatic-score-keeping Cornhole (Bags) board. We are presenting our project on Tuesday, December 10th.

Basically, for some background information, what we have right now is a the board with 10 Force Sensitive Resistor (our budget could only afford us to get 10, unfortunately) laid out strategically on the board. You can see how we set them up in the picture I have attached.

Then we cut tiles in to thirds and attached 0.5 inch thick and 1.5 inch square pieces of wood to the resistors and lightly nailed the tiles on top of them so that the resistors would register if there was a bag anywhere on the board. The resistors are split up in to 3 sections: the top 4, the middle 3, and the bottom 3. Each section is wired in parallel, and then underneath the board the 3 sections are wired in series. Then they are wired to the Arduino ATmega328. It is wired in to the 5V input, with the other terminal split between a wire with a 10K pull-down resistor that is wired to ground and a wire to the analog input 0.

We had to wire it like this because the resistors have infinite resistance with no force on them, and it decreases exponentially with more force. So, we couldn't wire them all in parallel because that would reduce the resistance too much and make it almost negligible. Furthermore, they also couldn't be wired in series because if one resistor had no pressure on it, there would be no voltage output.

Okay, so I have taken an introduction to C++ programming, but needless to say I wasn't very good at it (the reason I switched majors from Computer to Electrical Engineering, haha). Right now we found a basic program to read in the values from the board. What we need to do, now, is program it so that it can distinguish if there is 1 ,2 ,3 or 4 bags on the board for their team. What I think that would require would be to just throw bags on the board and read out the values and program it say if it is from a to b value that there is one bag and if the value is from x to y there is 2 bags on the board, etc... I also think there would need to be a loop for each team so after the person throws their bag they just hit a button to end their teams loop and start the other teams loop.

Also, we ran out of budget before we could get anything to read whether or not a bag has gone through the hole. We were just going to do a simple flipper switch, like on a pop-a-shot arcade game. It would basically just be a flipper switch to that when it makes a connection it tells the program that the bag has gone through the hole, which is worth 3 points in the game. So, if I could get the concept programming for that done, that would be great as well, but isn't necessary.

Then, comes the math part. Bags scoring works through cancellation. For example, if I have 3 bags on the board and one through the hole and the other team only has 2 then I would only get 3 points for my team while the other team gets none. So, I assume there will be a separate part in the code used to calculate each teams score. Also, in the game neither team can go over 21 points, and if they do their score goes back down to 11. So, a team wins when their score reaches 21 or if the score is 11-0. So, the program would need to terminate once one of those conditions is met.

Finally, there will also be a part of the code to output the values after each round (after each team has thrown their 4 bags), and output that a team has won once their score reaches 21-x or 11-0.

From my knowledge, there would need to be a lot of loops and if/then statements in the program. So, if anyone could help me write this program, I would be very grateful! Also, if there is anything I missed in the concept of the game or the programming and you could let me know, that would be awesome! Sorry for such a long post, as well, I just wanted to make sure I covered everything.

aachally:
SDSM&T

My alma mater. How's the weather?

...a automatic-score-keeping Cornhole (Bags) board...

A what?

So, if anyone could help me write this program, I would be very grateful!

The best way to get help on this forum is to make an attempt, post your code (use
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags), and then ask for help.

In my case, it would be very helpful to include a truth table for the sensors (e.g. when 1 bag is on sensor 1 the voltage at analog input 0 is...).

Finally, there will also be a part of the code to output the values after each round (after each team has thrown their 4 bags), and output that a team has won once their score reaches 21-x or 11-0.

Output to where?

The algorithm would seem to be simple.

Read the value of a resistor and decide whether there is something on it.
( I assume you tested this principle before you went to all the trouble to build your
apparatus ).

Repeat for the other 9 resistors.

Keep repeating until the battery is flat.