Program Your micro:bit Using Arduino IDE

Did you know that you can program your micro:bit using Arduino IDE?

INTRODUCTION

If you’re Arduino user and want to try micro:bit, you can program your micro:bit using Arduino IDE. In this tutorial, I will share with how to setup and program your micro:bit using Arduino IDE.

VIDEO

This video shows how to program your micro:bit using Arduino IDE

HARDWARE PREPARATION

This is the list of items used in the video.

Sample Code

micro:bit board json link

https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json

You can use following code for controlling LED and read push button status (basic lesson).

const int COL1 = 3; // Column #1 control
const int LED = 26; // 'row 1' led
const int BUTTON_A = 5; // The number of the pushbutton pin
const int BUTTON_B = 11; // The number of the pushbutton pin
long previousMillis = 0;
long currentMillis = 0;
int interval = 500;
boolean ledState = false;
boolean buttonAPressed = false;
boolean buttonBPressed = false;
void setup()
{
Serial.begin(9600);
Serial.println("microbit is ready!");
pinMode(BUTTON_A, INPUT);
pinMode(BUTTON_B, INPUT);
// Because the LEDs are multiplexed,
// we must ground the opposite side of the LED
pinMode(COL1, OUTPUT);
digitalWrite(COL1, LOW);
pinMode(LED, OUTPUT);
}
void loop()
{
currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
ledState = !ledState;
digitalWrite(LED, ledState);
}
if (digitalRead(BUTTON_A) == LOW &&
buttonAPressed == false) {
buttonAPressed = true;
Serial.println("Button A is pressed.");
}
else if (digitalRead(BUTTON_A) == HIGH &&
buttonAPressed == true) {
buttonAPressed = false;
}
if (digitalRead(BUTTON_B) == LOW &&
buttonBPressed == false) {
buttonBPressed = true;
Serial.println("Button B is pressed.");
}
else if (digitalRead(BUTTON_B) == HIGH &&
buttonBPressed == true) {
buttonBPressed = false;
}
}

Thank You

References:

  1. Nordic Semiconductor nRF5 Boards by Sandeep Mistry
  2. Adafruit – micro:bit with Arduino

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

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