Hi, I am building arcade game with 10 player buttons (5 for each player) and one start button. All buttons have build in LED inside. Player buttons has LED for 12V and start button has led for 5V. I am using ATMEGA2560 pro boar. I have also 4 TM1637 displays (two for each player) showing time and score. I am using 12V adapter. This is my schematic:
schematic.pdf (11.4 KB)
This is test code which I had:
#include <Arduino.h>
#include <TM1637Display.h>
#define BTN_A1_PIN 16
#define BTN_A2_PIN 18
#define BTN_A3_PIN 28
#define BTN_A4_PIN 26
#define BTN_A5_PIN 47
#define BTN_B1_PIN 44
#define BTN_B2_PIN 36
#define BTN_B3_PIN 39
#define BTN_B4_PIN 46
#define BTN_B5_PIN 37
#define LED_A1_PIN 13
#define LED_A2_PIN 17
#define LED_A3_PIN 11
#define LED_A4_PIN 15
#define LED_A5_PIN 19
#define LED_B1_PIN 25
#define LED_B2_PIN 27
#define LED_B3_PIN 23
#define LED_B4_PIN 21
#define LED_B5_PIN 29
#define BTN_START_PIN 32
#define LED_START_PIN 35
#define DISPLAY_A_SCORE_CLK 20
#define DISPLAY_A_SCORE_DIO 10
#define DISPLAY_A_TIME_CLK 40
#define DISPLAY_A_TIME_DIO 43
#define DISPLAY_B_SCORE_CLK 42
#define DISPLAY_B_SCORE_DIO 33
#define DISPLAY_B_TIME_CLK 34
#define DISPLAY_B_TIME_DIO 38
typedef struct
{
uint8_t btnIn;
uint8_t ledOut;
} btn_t;
btn_t btn[] = {
{
.btnIn = BTN_A1_PIN,
.ledOut = LED_A1_PIN,
},
{
.btnIn = BTN_A2_PIN,
.ledOut = LED_A2_PIN,
},
{
.btnIn = BTN_A3_PIN,
.ledOut = LED_A3_PIN,
},
{
.btnIn = BTN_A4_PIN,
.ledOut = LED_A4_PIN,
},
{
.btnIn = BTN_A5_PIN,
.ledOut = LED_A5_PIN,
},
{
.btnIn = BTN_B1_PIN,
.ledOut = LED_B1_PIN,
},
{
.btnIn = BTN_B2_PIN,
.ledOut = LED_B2_PIN,
},
{
.btnIn = BTN_B3_PIN,
.ledOut = LED_B3_PIN,
},
{
.btnIn = BTN_B4_PIN,
.ledOut = LED_B4_PIN,
},
{
.btnIn = BTN_B5_PIN,
.ledOut = LED_B5_PIN,
},
{
.btnIn = BTN_START_PIN,
.ledOut = LED_START_PIN,
},
};
TM1637Display displayAScore(DISPLAY_A_SCORE_CLK, DISPLAY_A_SCORE_DIO);
TM1637Display displayATime(DISPLAY_A_TIME_CLK, DISPLAY_A_TIME_DIO);
TM1637Display displayBScore(DISPLAY_B_SCORE_CLK, DISPLAY_B_SCORE_DIO);
TM1637Display displayBTime(DISPLAY_B_TIME_CLK, DISPLAY_B_TIME_DIO);
void setup()
{
for (int i = 0; i < 11; i++)
{
pinMode(btn[i].btnIn, INPUT_PULLUP);
pinMode(btn[i].ledOut, OUTPUT);
}
displayAScore.setBrightness(0x0f);
displayATime.setBrightness(0x0f);
displayBScore.setBrightness(0x0f);
displayBTime.setBrightness(0x0f);
displayAScore.showNumberDec(1111, false);
displayATime.showNumberDec(2222, false);
displayBScore.showNumberDec(3333, false);
displayBTime.showNumberDec(4444, false);
}
void loop()
{
for (size_t i = 0; i < 11; i++)
{
if(0 == digitalRead(btn[i].btnIn))
{
digitalWrite(btn[i].ledOut, HIGH);
}
else
{
digitalWrite(btn[i].ledOut, LOW);
}
}
}
And this is how it looks like inside:
The problem is ATMEGA2560 just burned. I was testing it firstly without TM1637(they were connected to power but I did not used lib for them at that time) and it was working okay (buttons were lighting up upon pressing). Then I added lib for TM1637 to code and for 2 seconds I saw "1111" "2222" ... so on as it is in code, so there is no bad connection. But after a 2 seconds it started buzzing (probably linear regulator temp protection was kicking in) and ATMEGA just burned. Now when I plug 12V in it gets hot pretty fast. I had always connected only 12V no power from USB. I know my wires are not shortest but I would not expect that MCU dies. Could you help please? I don't want to plug next 20€ chip just to see another expensive smoke.