Tuesday, 23 April 2019

Microbit Express V1.5(Remote controlled) in EduBlocks 2019


This is a recode of the original Micro:bit Express in EduBlocks. Here is the link to the original blog for context......link 

This is a follow on from this blog . This iteration builds upon the basic Micro:bit Express which goes forward and stops with a simple press of "a" and "b" button presses. This version adds the ability to remote control the Lego Train using a second Micro:bit.

Here is a picture of the Lego train......



here is the code for the motor controller..


Here is the XML file...... link
Here is the hex file......link

Here is the remote code......


Here is the XML file ..... link
Here is the hex file.......link

Cya 

If you like this blog check out all the others here

Microbit Express V1 in EduBlocks 2019




This is a recode of the original Micro:bit Express in EduBlocks. Here is the link to the original blog for context......link 


Here is Micro:bit Express set up.......and in action
Here is what the code looks like.....


Here is the link to the code editor...... link

Here is the code as a hex file.....link
Here is the code as an XML file that you can load straight into EduBlocks Micro:bit editor......link

Enjoy cya

If you like this blog check out all the others here

EduBlocks 2019


Here I will be linking to projects created / recreated using the new version of EduBlocks over the coming months.

Here you can see all my previous EduBlocks blogs / experiments.... link

This will be then new landing page / source of links for my future experiments.


Blog 1 Microbit Express V1 link

Blog 2 Microbit Express V1.5 Remote controlled link
















References / credit
Credit for the screen grabs of Edublocks icons are taken from the Edublocks website were created by Josh Lowe. 


Cya

If you like this blog check out all the others here

Saturday, 6 April 2019

Coventry and Warwickshire Jam '21 Stop frame Lego animations.


Here is the excellent creations by some of the attendees at today's mini jam at Coventry Central Library, using Martin O'Hanlon's GuiZero software.







If you like this blog check out all the others here

Sunday, 17 March 2019

Microbit Controlled Rollercoaster


Always keen to see what else I can motorise with Lego I bought the necessary bits to motorise a Lego roller coaster. I bought only the carts, track and chain links from brick link. link

I borrowed the Ferris Wheel car parts from my daughters Ferris wheel that I had previously "borrowed" to motorise. (See below)

I used some basic cogs and Lego Technic bits to drive the cars up the main ramp(see below). 


I reused the Micro:bit motor controller and Micro:bit I had used previously on the Micro:bit Express and Ferris Wheel blogs(See below).


I used the following code:
from microbit import *

def stop():
    pin8.write_analog(1023)
    pin12.write_analog(1023)

def forward(speed):
    pin8.write_analog(speed)
    pin12.write_digital(0)
    display.scroll(speed)

    
speed = 400 

while True:
    
    if button_a.was_pressed():
        display.scroll('F')
        forward(speed)
    
    if button_b.was_pressed():
        display.scroll('S')
        stop()

Updated code for incremental speed control:

from microbit import *

def stop():
    pin8.write_analog(1023)
    pin12.write_analog(1023)

def forward(speed):
    pin8.write_analog(speed)
    pin12.write_digital(0)
    display.scroll(speed)

    
speed = 400 

while True:
    
    if button_a.was_pressed():
        
        
        speed = speed + 50
        msg = "F" + str(speed)
        display.scroll(msg)
        if speed > 1000:
            speed = 400
        forward(speed)
    
    if button_b.was_pressed():
        display.scroll('S')
        stop()


Over :)

If you like this blog check out all the others here

Thursday, 21 February 2019

Gui Zero Lego animations


Lego stop frame animation using GuiZero and Pi Camera

(Now with added Twitter)


First of all this GuiZero app was made by Martin O'Hanlon last June you can read about it here. He has enabled you to take still images using a Pi camera and stitch them together to create an animated gif. Updated... 10/03/2019 now with added Twitter functionality. Explained at the bottom of the blog.

Here is what I did with it.......

1. I dug out my Pi Touch screen and bolted a Pi on the back. Then attached a Pi camera onto the pi.  

2. Cut out a hole in the box for the Pi touchscreen to locate the screen and taped it in place. I then cut a hole in the side of the box to push the key board and mouse and other cables through(See below). 



3. Then read Martin's instructions from his linked blog above about how to install the code and necessary libraries. 

4. Bodged together some Lego from my kids and set about testing it out. That is it. 

Here is my 2nd attempt......

Twitter update.....

After attempt 2 I decided to see if I could connect these gif animations to Twitter. Handily about 2 years ago I created a few Twitter bots following the RPI tutorial's. These days they are harder to get through the system. However here is the code that I used link  again I must stress the point that the original code was written by Martin O'Hanlon(the following blog explains his project  here).

Here is an example tweeted gif.....




enjoy :)


If you like this blog check out all the others here

Monday, 18 February 2019

Raspberry Pi Zero Express




Pi Zero Express aka Raspi Express 2.5(now with added bluedot control)

Over the last 6 months I've iterated between Pi and Micro:bit versions of the microboard controlled Lego train. Micro:bit version will always be visible given the size of the motor controller. Whereas with the Edu Kit 3 motor board with a Raspberry Pi Zero W you have the potential for hiding the brains in the actual train somewhere. In every single version up until last week the micro controller was visible. That changed last week end. Up until recently I have tried to bolt a full sized Pi onto the train motor, in the summer ModMyPi kindly gave me a Pi zero W with GPIO actually attached (you can buy here ).
I received it in August, it took until February to actually dig in and get into miniaturisation. So here is my account of how to get  a Lego Train to move without it looking like a horrific mess.

Over the last year we have accumulated three cheap find's on eBay. My main aim was to make it remote control so if my son / daughter felt like it they could do it with out loads of fussing about. To this point that hasn't been achievable given everything hanging out / everything being very brittle.

The other major problem that I have had to contend with is that I've tried to attach the motor and everything else to the train, which in hindsight was daft. Because if the kids wanted to swap out the train that would mean pulling out the cables and faff. So I decided to bury everything into the train carriage.  If the kids want to use the HP express or either of the other two available then they can simply attach the train they want and the carriage hides all the gubbins, there are no exposed cables to worry about.

Below you can see them all....


The set up


The height of the train carriage had to be raised to fit everything in.

Also I have added a few of the flat plates to minimise how secure the roof is so it is easier to remove and less likely to fall apart each time. (at the bottom is the Pi Zero W which has wireless built in, there is also a battery holder for 4 x AA batteries, which powers the motor.)


On top of that is a cheap phone power bank which powers the Pi Zero W. Then the roof fits on top.
I even managed to nick one character at the back.

I use white plastic strip to keep the battery from making contact with the battery box when the train is not being used, it stops the batteries from draining, plus I don't have to physically pull out the batteries. 

The first two or three iterations required bolting down the pi(3b+), battery to power the pi and the 4 x AA batteries to power the motor. As you can see from the previous blog it was some what clunky(link). The key to getting this to work as a remote controlled train has been GUIZero and RealVNC. GuiZero for the interface and RealVNC for the ability to connect to the Pi remotely from my Iphone(insert your own phone / tablet). You can read the respective links for how to set up RealVNC, GUIzero comes pre-installed with Raspian OS. 

The code

The code for this hasn't really changed a great deal since version 1.0, I have added a slider to adjust the speed. Currenly this version isn't on github, but I will be refining it soon and I will come back and update the link then. Link

Real VNC

Is free and makes it really easy to enable remotely logging into your pi. You can find out more here link.

The future iterations...



  • Running multiple trains
  • Using light sensor to stop at the station
  • Lights????
  • Improved GUI

Bluedot Control update.....

I have recently dug out the Pi Touch screen and wanted to use this to be able to control the Pi Express. The best idea I could think of was using Bluedot by Martin O'Hanlon link .

1. I followed these instructions to install the app for my Pi touch screen and the necessary libraries for the Pi Express Pi Zero W.

2. Then I wrote the following code on the Pi Zero W which controls the train link.

3. Run the python code on the Pi controlling the train

4. On the second Pi which will be used as the remote controller run the bluedot app. 

5. Then you should be able to swipe on the blue dot t control the train. 

swipe up to increase forward speed


swipe down to increase forward speed


swipe left or right to stop the engine


n.b. when the speed hits 1 it stops the motor and resets speed to 0.


Over

If you like this blog check out all the others here