/* jquery */ /* jquery accordion style*/ /* jquery init */
Showing posts with label LEGO®. Show all posts
Showing posts with label LEGO®. Show all posts

Raspberry Pi LEGO® Build Hat

Combine a LEGO® kit with the power and flexibility of a Raspberry Pi computer and you’ll open up endless possibilities for design, engineering and construction. However, there are a few challenges involved in interfacing LEGO® components to the Raspberry Pi board's ports.

But now this challenge has been greatly simplified by the release of the Official Raspberry Pi Build Hat and three other associated products.

The Build Hat

The new Official Raspberry Pi Build Hat is a $25 add-on board for your Raspberry Pi. It connects to the 40-pin GPIO header and can be used to control up to four LEGO® Technic™ motors and sensors from the LEGO® Education SPIKE™ Portfolio.

This new HAT works with all 40-pin GPIO Raspberry Pi boards, including Raspberry Pi 4 and Raspberry Pi Zero. Use a ribbon cable, or other extension device, and you can also connect it to a Raspberry Pi 400.

The Build Hat Python Library

To help budding LEGO® engineers bring their inventions to life the Raspberry Pi Foundation has released a Python Library for the Build Hat.

This library supports all the LEGO® Technic devices included in the SPIKE™ Portfolio, those associated with the LEGO® MINDSTORMS® Robot Inventor kit plus other devices that use an LPF2 connector.

The New Power Supply

LEGO® Technic motors are really powerful, which means to drive them you’ll need an external 7.5V power supply.

Fortunately, there's a brand-new $15 power supply for the Build HAT that’s both reliable and rugged to help make the most of those motors.

The LEGO® Maker Plate

The LEGO® Education SPIKE™ Prime Expansion Kit includes an exclusive LEGO element the Maker Plate - the first one designed to connect to something that isn’t another piece of LEGO®. The Maker Plate makes it super easy to add a Raspberry Pi to your LEGO construction.

LEGO® SPIKE™ Prime components are perfect for rapidly prototyping projects. There is a distance sensor, a colour sensor, and an incredibly versatile force sensor. While the angular motors come in a range of sizes and include integrated encoders you can query in order to find their position to precisely control movement, or as input devices in their own right.

If you don’t have a Maker Plate take a look at this list of Build Hat compatible LEGO® elements to help identify what works best for your project.

Discover the Raspberry Pi

LEGO® and micro:bit with Brown Dog Projects

I recently came across the Brown Dog Projects website and its selection of simple-to-build, easy-to-code LEGO® themed projects using low-price microprocessor boards like the popular micro:bit.

You can also buy a number of kits, including a micro:bit board kit.
This kit has a Crazy Circuits Bit Board to simplify LEGO® brick and micro:bit board connectivity, plus many other items including a USB Cable, Battery Holder, Small Pushbuttons, LEDs, Potentiometer, Piezo Speaker, LEGO® Compatible Servo and a few LEGO® pieces.

The video below captures some of the potential of this kit.

The Brown Dog Projects website also has a collection of step-by-step project guides

Read More LEGO® Posts

Anton's LEGO® Construction Projects

The web contains many sources of information on LEGO® programmable hub/brick technologies and the associated construction kits. One of these is from a guy called Anton.

Anton has a blog containing How-To tutorials which explain the steps required construct and program LEGO® robot projects, like the ones show in his videos.

For example, Anton has a Bluetooth wireless remote control of the EV3 hub/brick post which involves LEGO® SPIKE Prime, the MicroPython language and the PyBricks module.

Anton also has a large collection of inspirational LEGO® project videos going back over 10 years and covering various products including LEGO® NXT, LEGO® Technic, LEGO® Mindstorms and LEGO® SPIKE.

LEGO® and Python and PyBricks

Over the 20 years LEGO® have created a number of intelligent programmable hub/brick technologies for LEGO® MINDSTORMS, LEGO® TECHNIC, LEGO® CITY, LEGO® BOOST and most recently LEGO® SPIKE.

However, the ability to use the Python programming language for coding LEGO® hub/bricks is a more recent innovation. One of the Python coding options is a module called PyBricks.

PyBricks has a number of advantages:
• It is Open Source with source code on GitHub
• It is based on the popular MicroPython language
• You can run your code directly on the hub/brick
• There's an app to write MicroPython scripts
• You can send scipts to the hub/brick via Bluetooth
• It offers precise motor control
• It is compatible with all official sensors and motors

PyBricks version 2.0 was a little limited in hub/brick support. But now, with PyBricks 3.0 Beta, there's support many more LEGO® platforms, including LEGO® BOOST, LEGO® TECHNIC Control+ and LEGO® City Trains.

LEGO® SPIKE™ and MicroPython

LEGO® SPIKE™ is an education-level product from the LEGO® intelligent programmable hub/brick family.

LEGO® SPIKE™ simplifies the connection of motors and sensors - such as touch, distance-ultrasonic, and color/light - and provides a programming interface via the popular Scratch coding language.

LEGO® SPIKE™ brick/hub has six ports, a speaker, a 5x5 light matrix, a 6-axis gyroscope, Bluetooth wireless communication and a rechargeable battery.
The LEGO® SPIKE™ Prime kit adds motors, sensors and 525 technic-style bricks to create a rapid robotics development environment.

Interestingly, internally this intelligent brick/hub runs MicroPython. And, you can open a connection to a REPL session and enter commands to control the SPIKE™ brick/hub - as shown on the instructables website.

And now, with version the Education SPIKE™ 1.3 app update, LEGO® officially provide full language support for the Python Knowledge Base coding, as shown by the message below taken from a LEGO® SPIKE™ webpage.

LEGO® Education SPIKE™ Prime lets your students dip their toes into text-based coding with a beginner-friendly Python experience. Python is a coding language widely used in robotics and it lays a strong foundation for tackling more advanced topics like algorithms, data structures, machine learning, and artificial intelligence.

More LEGO® Boost Python Coding

As my original LEGO® Boost kit and Python coding post has received quite a number of page views I thought I'd post some additional information on this topic.

Andrey Pokhilko

I recently came across Andrey Pokhilko and his YouTube video (below). In this video he talks about his own LEGO® Boost Robotics construction and coding project, along with a demonstration of Vernie's capabilities plus a custom power pack hack.

To view Andrey's Python code examples navigate over to his GitHub resources page.

Mikhail Zakharov

I also noticed Mikhail Zakharov has added Python coded Voice Command Control to his own LEGO® Boost Vernie project.

Mikhail's Python source code can be found on his GitLib resources page.

Try My Free Python Coding Tutorials

LEGO® Boost and Python Coding

The LEGO® Boost kit is all about delivering a simplified route into robotics.

You can create models using standard LEGO® bricks. And there's an easy-to-get-started block-based coding app for iOS and Android.

The kit's Move Hub accepts a real-time stream of code instructions, sent via bluetooth, to interact with the built-in motors, LEDs and sensors.

However, it's also possible to interact with the Move Hub using Python, a far more flexible alternative block-based coding.

First you'll need a Python installation on your PC, Mac or Raspberry Pi 3B/3B+/3A+ or Zero W.

You'll also have to install some dependencies:

sudo apt-get install python3-pip
sudo pip3 install pexpect
sudo pip3 install pygatt

Then install the LEGO® Boost Python library module:

wget https://github.com/undera/pylgbst/archive/master.zip
unzip master.zip
cd pylgbst-master
sudo python3 setup.py install

To find out more on using Python with LEGO® Boost (and get to access to plenty of code samples) check out the series of articles by Mike Cook in the official Raspberry Pi magazine, starting at issue 80.

And read my More LEGO® Boost Python Coding post for additional inspiration.

My Free Raspberry Pi Python Coding Tutorials