James Caska
Published © MIT

Touch Logic Control for VBB with Ada micro:bit Interpreter

TLC is a visual programming language that records microcontroller actions as a visual interactive storyboard and replays them as a program.

BeginnerProtip1 hour208
Touch Logic Control for VBB with Ada micro:bit Interpreter

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1

Software apps and online services

Virtual Breadboard Windows Store App
GNAT Community
AdaCore GNAT Community

Story

Read more

Code

TLC Firmware for micro:bit

ADA
The companion TLC firmware for the micro:bit to work with Virtual Breadboard TLC-Disco examples.
Version 0.1 - Initial basic release that enables the Buttons IO to work with VBB.
Build with the GPS Toolchain using the drivers from https://github.com/AdaCore/Ada_Drivers_Library
-- TLC Tether Firmware 0.1 
with MicroBit.Display;
with MicroBit.Buttons; use MicroBit.Buttons;
with MicroBit.Time;
with Ada.Text_IO; 

procedure Main is
buttonA : Button_State := Released;
buttonB : Button_State := Released;
   
begin
   MicroBit.Display.Display_Async("Ada4Vbb!");
   -- Initialise
   buttonA := MicroBit.Buttons.State (Button_A);
   buttonB := MicroBit.Buttons.State (Button_B);

   loop

      -- Detect Button A Events
      if MicroBit.Buttons.State (Button_A) = Pressed then
         if buttonA /= Pressed then
            buttonA := Pressed;
            Ada.Text_IO.Put_Line ("A");
         end if;
      else
         if buttonA /= Released then
            buttonA := Released;
            Ada.Text_IO.Put_Line ("a");
         end if;
      end if;

      -- Detect Button B Events
      if MicroBit.Buttons.State (Button_B) = Pressed then
         if buttonB /= Pressed then
            buttonB := Pressed;
            Ada.Text_IO.Put_Line ("B");
         end if;
      else
         if buttonB /= Released then
            buttonB := Released;
            Ada.Text_IO.Put_Line ("b");
         end if;
      end if;
   MicroBit.Time.Delay_Ms (20);
   end loop;
end Main;

main.bin

ADA
Pre-Build version of TLC Tether 0.1
Plug in micro:bit to show the virtual hard drive of the micro:bit.
Drag and drop this binary file into the virtual drive to program it.
The micro:bit should display VBB4Ada on the LCD.
You can then use the buttons as event generators for the virtual micro:bit in Virtual Breadboard.
No preview (download only).

Credits

James Caska

James Caska

18 projects • 32 followers
Creator of VirtualBreadboard

Comments