Hey, i have been working on a "Console" of sort using the atmega328p, but i wanted to implement a sort of "Cartridge" and i wanted to use an IF statement to check for cartridge and ignore the current program.
It works like this:
No cartridge inserted: Play the default game
Cartridge detected while the default game is running: Keep playing the default game, communicate to the cartridge to not send any instructions
Cartridge detected after reboot: Play the game from the cartridge, communicate to the onboard atmega328p to not send any instructions.
I Wanted to use an 16x2 LCD, and to connect it to the atmega328p AND the cartridge port.
I used digital pin 3 to sense if the cartridge is in using this code inside the void setup():
//some code, not important.
pinMode(3, INPUT);
btn = digitalRead(3);
if (btn == HIGH)
{
while(1) {}
}
//the actual game code
I have no idea why, but it just goes right into the actual game code.
I do use the arduino bootloader, if it's important.