Control LED on EDU:BIT Using IoT Blynk App and Raspberry Pi

Control LED on EDU:BIT Using IoT Blynk App and Raspberry Pi


Continue from previous tutorial, since the Raspberry Pi has WiFi, I will try to control the LEDs in EDU:BIT using the Blynk app. The idea is, I will program the Raspberry Pi to read data on the Blynk server, and then send the data to EDU:BIT via serial USB communication. Then the EDU:BIT will control the LED based on the data received.


This video shows how to control LED on EDU:BIT using IoT Blynk app and Raspberry Pi.

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is python sample program for micro:bit (top) and Raspberry Pi (bottom). You can use mu editor to program micro:bit and Thonny Python IDE to run program in Raspberry Pi. Please install python Blynk library with following command.

sudo pip3 install blynk-library-python
from microbit import *
import music["C4:1", "G4:1"])
pot_value = 0
pot_prev = 0
data_in = ''
while True:
# Read serial uart data from Raspberry Pi and control LEDs
data_in =
pin16.write_digital(int(data_in) & 1)
pin15.write_digital((int(data_in) & 2) >> 1)
pin14.write_digital((int(data_in) & 4) >> 2)

from gpiozero import LED, Button, Buzzer
from time import sleep
import serial
import BlynkLib
# Replace with your microbit port number
PORT = "/dev/ttyACM0"
BAUD = 115200
s = serial.Serial(PORT)
s.baudrate = BAUD
s.parity = serial.PARITY_NONE
s.databits = serial.EIGHTBITS
s.stopbits = serial.STOPBITS_ONE
s.timeout = 1
BLYNK_AUTH = 'Your Auth Blynk Token'
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Register virtual pin handler
def v0_write_handler(value):
global ledStatus
global led1State
led1State = int(value[0])
print("V0: {}".format(led1State))
if led1State == 1:
ledStatus = ledStatus + 1
ledStatus = ledStatus 1
def v1_write_handler(value):
global ledStatus
global led2State
led2State = int(value[0])
print("V1: {}".format(led2State))
if led2State == 1:
ledStatus = ledStatus + 2
ledStatus = ledStatus 2
def v2_write_handler(value):
global ledStatus
global led3State
led3State = int(value[0])
print("V2: {}".format(led3State))
if led3State == 1:
ledStatus = ledStatus + 4
ledStatus = ledStatus 4
led1State = 0
led2State = 0
led3State = 0
ledStatus = 0
prevLedStatus = 1
blynk.virtual_write(0, 0)
blynk.virtual_write(1, 0)
blynk.virtual_write(2, 0)
while True:
if ledStatus != prevLedStatus:
print("LED Status: {0:03b}".format(ledStatus))
prevLedStatus = ledStatus

view raw
hosted with ❤ by GitHub

Thank You


Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

DIY Digital Alarm Clock Using REKA:BIT With Micro:bit
Display Internet Time (NTP) on micro:bit
DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
Tutorials of Cytron Technologies Scroll to Top