I'm having a little trouble wrapping my head around the best way to assess the following question:
Write a program that will light up the blue LED. Use a variable [called blueLED] so that if you decide to hook up the LED to a different pin, you can quickly change your code to match.
Ideally I would not have to include the test inside the square brackets, but I suspect that will make creating this question much easier.
To provide context, here's a picture of the circuit with an ideal programming solution:
I already know how to assess whether students are able to write a program that will light up the blue LED, but I don't know the best way to go about making sure they created a variable and used it.
For example, the following code would still pass my test:
void setup() { pinMode(4,OUTPUT); digitalWrite(4,HIGH); } void loop() { }
I know I can turn it into a cpp_via_python question (or in my case, an arduino_via_python question), and alter the template to check for a blueLED string, but finding blueLED does not necessarily mean that it was used correctly. For example, the following would light up the LED and pass a string search test for blueLED:
int blueLED = 4; void setup() { pinMode(blueLED,OUTPUT); digitalWrite(4,HIGH); } void loop() { }
I'm thinking that maybe a better way to handle this would be to alter the setup so that the first line assigns different values to blueLED and see if I get the expected output. For example:
void setup() { blueLED = {{testcases}} ... }
I could then check for the expected output. The problem is, I don't know how to hijack the students' setup so that it will run that additional line of code.
I'm not sure my approach is the best. I'm open to any solution that gets my students writing readable and maintainable code.