Skip to main content

Pimoroni Flotilla first play with Python.



The Mega Treasure Chest Flotilla set from Pimoroni, was kickstarter project that got a lot of people interested. A nice package - a hub for a collection of devices such as light sensors, barometer, temperature, switches, motors and many more; all linked to a Raspberry Pi. The kit is shown in the image to the left.



A Python API exist for this system. Instructions on how to set up the Flotilla to work with Python can be found at http://flotil.la/start/ .

I wanted to play with switching the Rainbow (A set of RGB LEDs) outputs to Red, Blue and Green by pressing either 2,3, or 4 on the Touch Sensor as in the images.





Using the mini-kit example from https://github.com/pimoroni/flotilla-python/blob/master/examples/mini-kit.py as the basis, produced a simple system that uses the Touch module and its buttons 2,3 and 4 to change the Rainbow; the code is shown below and ran on a Raspberry Pi 3 using Python 3.


import colorsys
import flotilla
import time

client= flotilla.Client(
    requires={
        'one':flotilla.Rainbow,
        'two':flotilla.Touch
    })

def module_changed(channel,module):
    rainbow=client.first(flotilla.Rainbow)
    if module.is_a(flotilla.Touch):
        if module.one:
            rainbow.set_pixel(0,255,0).update()
        else:
            rainbow.set_pixel(0,0,0).update()

while not client.ready:
    pass

touch=client.first(flotilla.Touch)
rainbow=client.first(flotilla.Rainbow)
hue=0
lights_on= True

try:
    while True:
        if touch.one:
            lights_on = not lights_on
        if touch.two:
            rainbow.set_all(255,0,0).update()
        if touch.three:
            rainbow.set_all(0,255,0).update()
        if touch.four:
            rainbow.set_all(0,0,255).update()

        time.sleep(0.5)

except KeyboardInterrupt:
    client.stop()


The video below shows the system in action.




I look forward to playing with it a bit more and I would love to hear what others are doing with the Flotilla.


An other example of Python and Flotilla in action can be seen at 

 http://home.uktechreviews.com/Raspberry/Pi%20blog/files/flotilla1.html 

Related links

All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with.

Comments

Popular posts from this blog

Robot Software

In the previous blog posts for this 'series' "It is a good time...."  Post 1  looked at the hardware unpinning some of this positive rise in robots; Post 2  looked at social robots; Post 3  looked at a collection of small robots; Post 4 looked at further examples of small robots Robots, such as the forthcoming Buddy and JIBO, will be based some established open sourceand other technologies. Jibo will be based around various technologies including Electron and JavaScript (for more details see:  http://blog.jibo.com/2015/07/29/jibo-making-development-readily-accessible-to-all-developers/ ). Buddy is expected to be developed around tools for Unity3d, Arduino and OpenCV, and support Python, C++, C#, Java and JavaScript (for more details see http://www.roboticstrends.com/article/customize_your_buddy_companion_robot_with_this_software_development_kit ).  This post contin ues with some of the software being used with the smaller robots.  A number ...

Speech Recognition in Scratch 3 - turning Hello into Bonjour!

The Raspberry Pi Foundation recently released a programming activity Alien Language , with support Dale from Machine Learning for Kids , that is a brilliant use of Scratch 3 - Speech Recognition to control a sprite in an alien language. Do the activity, and it is very much worth doing, and it will make sense! I  would also recommend going to the  machinelearningforkids.co.uk   site anyway it is full of exciting things to do (for example loads of activities  https://machinelearningforkids.co.uk/#!/worksheets  ) . Scratch 3 has lots of extensions that are accessible through the Extension button in the Scratch 3 editor (see below) which add new fun new blocks to play with. The critical thing for this post is  Machine Learning for Kids  have created a Scratch 3 template with their own extensions for Scratch 3 within it  https://machinelearningforkids.co.uk/scratch3/ . One of which is a Speech to Text extension (see below). You must use this one ...

Escape the Maze with a VR robot - Vex VR

You don't need to buy a robot to get programming a robot, now there are a range of free and relatively simple to start with robot simulators to play with. Three examples are listed below: - Make code for Lego EV3  https://robotsandphysicalcomputing.blogspot.com/2020/05/programming-robots-virtually-3-lego-ev3.html   - i Robot simulator  https://robotsandphysicalcomputing.blogspot.com/2020/04/programming-robots-virtually-2-irobot.html - Vex robotics Vexcode VR   https://robotsandphysicalcomputing.blogspot.com/2020/04/programming-robots-virtually-1-vexcode.html   It is the last one of these ( https://www.vexrobotics.com/vexcode-vr ) that is the focus of this post and return to hit, after an earlier discussion in  https://robotsandphysicalcomputing.blogspot.com/2020/04/programming-robots-virtually-1-vexcode.html   .  Two of the nice things about the package, apart from being free, are it uses a Scratch-like programming language and it provides a ...