BhavithiranSuad AnwarSC Lim
Published © MIT

EDU:BIT Object Counter With Mini Conveyor | MicroPython

Guide to program Object Counter With Mini Conveyor with EDU:BIT (project kit for micro:bit) using MicroPython

BeginnerFull instructions provided30 minutes473
EDU:BIT Object Counter With Mini Conveyor | MicroPython

Things used in this project

Hardware components

EDU:BIT
Cytron Technologies EDU:BIT
×1

Software apps and online services

Mu
Python Editor for micro:bit

Story

Read more

Code

Object Counter With Mini Conveyor

Python
This tutorial's full code
from edubit import *
import music                                    # import music module

count = 0                                       # set 'count' variable to 0
while True:
    init()                                      # initialize EDU:BIT
    if is_IR_sensor_triggered():                # IR sensor triggered
        count += 1                                
        music.play(music.BA_DING)               # play melody
    if button_a.is_pressed():                   # button A pressed
        run_motor(M1,Forward, speed=200)        # run motor M1 at speed 200
        set_led(Red, 0)
        set_led(Green, 1)                       # turn on green led
    if button_b.is_pressed():                   # button B pressed
        brake_motor(M1)                         # brakes motor
        set_led(Red, 1)                         # turn on red led
        set_led(Green, 0)
        count = 0
    display.show(count)                         # show count value in microbit display

Credits

Bhavithiran

Bhavithiran

16 projects • 5 followers
Suad Anwar

Suad Anwar

1 project • 2 followers
SC Lim

SC Lim

13 projects • 7 followers
Design engineer | Husband · Dad | Loves tinkering & making

Comments

Add projectSign up / LoginAbout BBC micro:bit