/* jquery */ /* jquery accordion style*/ /* jquery init */

Capture Button Press (micro:bit MicroPython)

This little program display a different image when the 'A' and 'B' buttons are pressed.

from microbit import *

while True:
   if button_a.is_pressed():
   if button_b.is_pressed():

Here we use a While True: statement which create an endless loop. Make sure you use the correct indentation levels for the code inside the loop and inside the 'if' test statements to avoid errors when the program runs.

After you've downloaded and run this program on the micro:bit try changing the image names for the A and B buttons.

Return to the micro:bit MicroPython Coding Tutorials page.

No comments: