Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The challenge

Now it’s your turn to put polling into practice. Your task is to implement a simple program that uses button polling to display directional arrows based on user input:

  • If Button A is pressed, display a left arrow (←) on the LED matrix.
  • If Button B is pressed, display a right arrow (→) on the LED matrix.
  • If neither button is pressed, display a single lit LED at the center of the matrix.

You'll need to:

  • Initialize the variables for the LED and the buttons.
  • Continuously poll Button A and Button B.
  • Update the LED display according to the button state with a clear indication of each state (left, right, or neutral).

I hope you don't mess up! It's so hard to share the road with people who don't use their turn signals properly.