heya.
First off, I'm a noob to Arduino in general. I've run through the tutorials that came with my kit and have a basic grasp at it. Professionally, I'm a software engineer, so I have things covered on that front.
My problem is that I have a basic setup with a 7 segment LED that is working as intended, but I also have 3 buttons wired up on a separate breadboard that are causing me problems. The 7 segment LED is wired up to digital ports 2-8. The buttons are wired up to digital 10-12. Button 12 responds as intended, however 10 and 11 cause the Arduino to apparently crash and reset.
I've tried disconnecting input 12 to see if there was some sort of conflict between it and the other 2 buttons, but the results are the same. All 3 are wired up the exact same.
Here's my code:
int buttona = 12;
int buttonb = 11;
int buttonc = 10;
int sega = 2;
int segb = 3;
int segc = 4;
int segd = 5;
int sege = 6;
int segf = 7;
int segg = 8;
int counter = 0;
byte numbers[10][7] = {{1,1,1,1,1,0,1},
{0,1,1,0,0,0,0},
{1,1,0,1,1,1,0},
{1,1,1,1,0,1,0},
{0,1,1,0,0,1,1},
{1,0,1,1,0,1,1},
{1,0,1,1,1,1,1},
{1,1,1,0,0,0,0},
{1,1,1,1,1,1,1},
{1,1,1,1,0,1,1}};
void displayNum(int num) {
for (int i = 0;i<8; i++) {
digitalWrite(i+2,numbers[num][i]);
}
}
// the setup routine runs once when you press reset:
void setup() {
pinMode(buttona, INPUT);
pinMode(buttonb, INPUT);
pinMode(buttonc, INPUT);
pinMode(sega, OUTPUT);
pinMode(segb, OUTPUT);
pinMode(segc, OUTPUT);
pinMode(segd, OUTPUT);
pinMode(sege, OUTPUT);
pinMode(segf, OUTPUT);
pinMode(segg, OUTPUT);
displayNum(0);
}
// the loop routine runs over and over again forever:
void loop() {
if (digitalRead(buttona) == 0) {
if (counter < 9) counter++;
}
if (digitalRead(buttonb) == 0) {
if (counter > 0) counter--;
}
if (digitalRead(buttonc) == 0) {
counter = 0;
}
displayNum(counter);
delay(500);
}
Images of my layout: