pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://microbit.org/projects/make-it-code-it/counter/

ttps://cdn.sanity.io/images/ajwvhvgo/production/2486f833867850a1894ce9462d6e3196eeaabae1-800x400.png?q=95"/>Counter | micro:bit
Skip to content

Activity

Counter

Beginner | MakeCode, Python | Buttons, LED display | 15 Life on land, Input/output, Variables

Step 1: Make it

What is it?

A simple project to help you count... skips, jumps, birds you see out of your window - anything!

These two videos show you what you'll make and how to code it:

Introduction

Coding guide

How it works

  • This program uses a variable called 'count' to keep track of the number you're counting.
  • It sets the variable to 0 at the start.
  • Every time you press button B, it increases the count variable by 1 and shows it on the LED display.
  • Numbers over 9 won't stay on the display, so pressing button A shows the number.
  • You can reset the counter by pressing buttons A and B together.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode editor
  • battery pack (optional)

Step 2: Code it

1from microbit import *
2
3count = 0
4display.show(count)
5
6while True:
7    if button_a.is_pressed() and button_b.is_pressed():
8        count = 0
9        display.scroll(count)
10    elif button_b.is_pressed():
11        count += 1
12        display.scroll(count)
13    elif button_a.is_pressed():
14        display.scroll(count)
15    sleep(100)

Step 3: Improve it

  • Find another way of resetting the counter, for example by shaking the micro:bit.
  • Showing the number graphically - use a bar chart or dots.
  • Show a heart or another picture when you reach a certain number - it could be your target for star-jumps or another activity.
  • Use radio to send the count number to another micro:bit acting as a remote display.
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy