Can you imbed another command in your IR control system?
If not then you need to define the "event" to trigger the check.
The event can call a function to blink the built in led on pin 13.
Pressing the reset button seems like an obvious choice.
Just modify "blinky" and put it at the top of your program.
This waits 5 seconds after reset.
Then it blinks the LED 4 time with progressively longer blinks.
(of course anyone with a watch can figure out how to duplicate it)
//
const byte builtinled = 13;
int DelayTime=1000;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(builtinled, OUTPUT);
digitalWrite(builtinled, LOW);
delay (5000); // normal reset blins LED as well, make this obvious diffence
do {digitalWrite(builtinled, HIGH);
delay (DelayTime);
digitalWrite (builtinled, LOW);
delay (DelayTime);
DelayTime=DelayTime + 1000;
} while (DelayTime < 5000);
/* continue here with the rest of your setup code */
}
void loop() {
/* program code */
}
You could also create a const at the top of the declares and check its value in startup.
Something like a signature. This would require a bit more effort to duplicate.
In this manner you could also have a different "HEX" file for each student.
//
const byte builtinled = 13;
const unsigned long MyId = 123456789;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(builtinled, OUTPUT);
digitalWrite(builtinled, LOW);
delay (5000); // normal reset blins LED as well, make this obvious diffence
if (MyId == 123456789)
for (int i= 0; i<5; ++i)
{ digitalWrite(builtinled, HIGH);
delay (500);
digitalWrite (builtinled, LOW);
delay (500);
}
else
{ digitalWrite(builtinled, HIGH);
delay (5000);
digitalWrite (builtinled, LOW);
}
// end if
/* continue here with the rest of your setup code */
}
void loop() {
/* program code */
}
If you want more sophisticated: your free ram at start up should always be the same.
You can check that value easily and blink a different sequence if it does not match the known value.
This would take a bit of trial and error to get the right "test" number.
This of course assumes that any new code would need to use RAM space.
/* http://stackoverflow.com/questions/960389/how-can-i-visualise-the-memory-sram-usage-of-an-avr-program */
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
Even more sophisticated would be to read all the progmem and build a checksum to match.
Mark Sproul wrote a program called "Arduino Exploer" in 2010. It shows how to dump various memory locations.
The copy I have uses the depreciated PROGMEM syntax.
Still you might be able to get some ideas from that.
http://playground.arduino.cc/Main/ShowInfo
http://www.avr-developers.com/arduino_exp.html
By going to preferences and selecting "Show verbose output during: " upload
you can capture the avrdude command line from the console window:
C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude
-CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf
-v -v -v -v -patmega328p -carduino -P\\.\COM12 -b57600 -D -Uflash:w:
C:\Users\last.first.domain\Documents\Arduino\Build\My_ID.cpp.hex:i
I broke it into separate lines to make it easier to read.
You will find the HEX file in your build directory and the build directory is much easier to find if you set the "build.path" in preferences.txt
Your students would likely need to change the com port (Microsoft Windows is NOT known for consistency).