Touch Emotion Badge – MicroBit

Step 1: Make it

What is it?

Add another expression to an emotion badge project using the new micro:bit’s touch logo sensor as an extra button

Introduction

Coding guide

What you’ll learn

  • How computers take inputs, process them using code and create different outputs
  • How to use the new micro:bit’s touch logo like a button input to trigger outputs

How it works

  • This program senses if you press button A and shows a happy face icon on the LED display output.
  • It senses if you press button B and shows a sad face on the LED display.
  • If you touch the gold logo on the front of the new micro:bit, the program detects your finger and shows a surprised face on the LEDs.

What you need

  • new micro:bit with sound (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

Step 2: Code it

from microbit import *

while True:
    if button_a.is_pressed():
        display.show(Image.HAPPY)
    if button_b.is_pressed():
        display.show(Image.SAD)
    if pin_logo.is_touched():
        display.show(Image.SURPRISED)

Step 3: Improve it

  • Change the icons that appear, or draw your own to show different emotions.
  • Create an animated sequence of faces when you press each button.
  • Add different sounds that match each emotion.

Content Credit And Source- MicroBit Website

Leave a Reply

Your email address will not be published. Required fields are marked *