In the last lesson, you learned how to turn on LED on and off using digitalwrite, with a bit of set up from pinmode. In this lesson,
lets make a math-test program that asks students a math problem. If they get it right, we'll turn on a green LED. If wrong, a red LED.
Now you try. Go for it! Build us a right/wrong light-up math tester!
Type your code here:
See your results here:
This code will not run! First, fix the random statement to reflect the range of numbers that you wish to have in your math test. Then,
following the logic, see how the variable sum holds the correct answer, and ans is the
answer the person typed? Given that the red LED (for the wrong answer) is on pin 13 and the green LED (for the correct answer)
is on pin 12, fix the if statement condition and the two digitalwrite line make this all happen.
Here is what your Arduino assembly should look like for this lesson:
Share your code
Show a friend, family member, or teacher what you've done!