I am working on a new product development class at OU where my team is designing a learning board for 3-8 year olds. We have the board completed but it was suggested that we add some sort of electronic component to make it more interesting for the children. It is sort of like plinko where a puck is dropped through as series (set up by the children) of shapes to guide the puck to a slot in the bottom of the board. The "problem" is a card with three pins that will connect to a breadboard on top of the unit. There are seven slots and seven proximity sensors located in the bottom of each. The arduino should read the pins in the card to tell it which slot has the correct answer, and when the puck breaks the correct sensor it will light up a series of LED's around the board as well as play a victory song on a pizeo speaker.
The problem I am having is writing the code. I have very limited experience with arduino, but I have some. I am reading the sensors in on pins D13 through D7. I have the lights and speaker on D6 and D5. D2, D1, and D0 will be connected to read the pins.
The problem card has three pins in each one. One will read in as the number 4, the next the number 2, and the last, the number 1. Depending on which ones are grounded, I can read in 1-7. Below is my code (and my notes). I can program the lights and the buzzer, but I cannot figure out how to "connect" the sensor to the integer I get from the card.
Any help is greatly appreciated.
void setup() {
// put your setup code here, to run once:
//Read Pins
pinMode(13, INPUT);
pinMode(12, INPUT);
pinMode(11, INPUT);
pinMode(10, INPUT);
pinMode(9, INPUT);
pinMode(8, INPUT);
pinMode(7, INPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
pinMode(0, OUTPUT);
int f1;
int f2;
int f3;
bool fLand = false;
bool fB0;
bool fB1;
bool fB2;
bool fB3;
bool fB4;
bool fB5;
bool fB6;
int Answer = f1 + (2 * f2) + (4 * f4); // equals 0-7. These are the pins. Set low when tripped high they
are 1,
// set low (not connected)they are low and will return a zero. This
should give me my integer to show the program which slot is correct.
}
void loop() {
// put your main code here, to run repeatedly:
if fLand // Breaks a sensor
{
fcorrect = fB0 && ans == 0 || fB1 && ans == 1 || fB2 && ans = 2 || fB3 && ans == 3 || fB4 && ans == 5 || fB5 && ans == 6
// lights and buzzer
}
else
{
// Buzzer wrong