I´m electronic teacher in a school in Brazil, so we have some issues with our students, because many times they make some mistakes with input pins and output pins. So, for a schoolar purpouse, I´m trying to modify the Arduino UNO bootloader, letting digital inputs 2 to 8 only in input mode and inputs 9 to 13 only output mode, but I don´t know exactly how to do this.
1 - Is it possible?
2 - How can I do it?
3 - Is there another way to force the compiler to understand the pins as input or output only and don´t allow the users to modify it?
In the core? Yes. Sort of. You could modify pinMode() to check which pins were allowed to be set to input or output, BUT... anything can be worked around. It's the kind of thing that would be far too easy for even a moderately determined individual to get around.
In the compiler? Way more work I'd think. And still far too easy to work around to justify it.
I can use a diode to avoid mistakes but, offering a code protection and forcing the students to use my pin suggestions, is a easy way to avoid output with output connections, for example.
Some students did wrong connections as output with output and damage the arduino chip. So I can use a optocoupler or a diode, but in the course we need to learn basics for the students and they don´t know much about electronics. So forcing my students (in the beggining) to use my code suggestions is a better way.
But that´s ok, I´ll think in a better sollution. Thank you all a lot best regards