I'm trying to make a Plinko board using the Arduino, and I'm just trying to get a score to display after a micro limit switch is activated. I've tested the limit switches using a basic button program included in the "examples" tab of the Arduino, and they work with the five volts. Here's my code. I'm really stumped, so any help would be much appreciated.
#include <LiquidCrystal.h>
#define RS_Pin 7
#define ENABLE_Pin 8
#define D4_Pin 9
#define D5_Pin 10
#define D6_Pin 11
#define D7_Pin 12
LiquidCrystal LCD =
{RS_Pin, ENABLE_Pin, D4_Pin, D5_Pin, D6_Pin, D7_Pin};
byte PointNum;
byte Points;
bool WhateverPin1;
bool WhateverPin2;
bool WhateverPin3;
bool WhateverPin4;
bool WhateverPin5;
void setup()
{
pinMode(1, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
};
void loop()
{
WhateverPin1 = digitalRead(2);
WhateverPin2 = digitalRead(3);
WhateverPin3 = digitalRead(4);
WhateverPin4 = digitalRead(5);
WhateverPin5 = digitalRead(6);
if (WhateverPin1 == HIGH)
{
PointNum = 1;
PegBoard();
};
if (WhateverPin2 == HIGH)
{
PointNum = 2;
PegBoard();
};
if (WhateverPin3 == HIGH)
{
PointNum = 3;
PegBoard();
};
if (WhateverPin4 == HIGH)
{
PointNum = 4;
PegBoard();
};
if (WhateverPin5 == HIGH)
{
PointNum = 5;
PegBoard();
};
};
void PegBoard()
{
switch (PointNum)
{
case 1:
Points = 10;
break;
case 2:
Points = 15;
break;
case 3:
Points = 50;
break;
case 4:
Points = 30;
break;
case 5:
Points =100;
break;
};
LCD.setCursor(1, 0);
LCD.println("Your score is: ");
LCD.setCursor(14, 1);
LCD.println(Points);
delay(1000);
LCD.clear();
};