Showing posts with label pimoroni. Show all posts
Showing posts with label pimoroni. Show all posts

Monday 28 June 2021

Pimoroni Envirobit - Light and LED

In a previous post, the Envirobit ( https://shop.pimoroni.com/products/enviro-bit )  for the Microbit was played with getting temperature, humidity and pressure  (https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit.html). 

In this short post a quick experiment using the sound and light sensor, to turn LEDs on the board to turn off and on beyond on light level. The code is set up when a clap happens nearby, light level is used to 'decide' whether the LEDs are turned on or off, below a threshols the LEDs go on above it the LEDs are turned off,

Makeecode 


Using Makecode makes this relatively easy to implement and fun.








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. Twitter @scottturneruon

Monday 11 April 2016

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.

Saturday 9 April 2016

Experiences with Raspberry Pi Touch Screen

Well for once I am not going to be talking about robots, but my experience in setting up a Raspberry Pi touch screen - this is not a how to guide, a couple links to those are included in the post, but my experience of setting one up. 

So the I bought the Raspberry Pi Touch Screen from Pimoroni and along with the stand/frame for it.

Setting up the LCD frame was simple with the instructions provided and the link at the end of the instructions provide some further help http://learn.pimoroni.com/tutorial/pi-lcd/getting-started-with-raspberry-pi-7-touchscreen-lcd on setting up the screen

A tutorial from The PiHut (https://thepihut.com/blogs/raspberry-pi-tutorials/45295044-raspberry-pi-7-touch-screen-assembly-guide) was very useful on how to connect the screen to the Pi. The blue side  on the white ribbon cable (provided with the screen) used in connecting the two together needs to blue side down towards the LCD (as explained in PiHut tutorial) and facing away from the Pi when connecting to it, which is the bit I was unsure of. Connecting the power via the jumper leads that came with the screen means only a single power supply is need for both the screen and Pi. If you follow the  PiHut tutorial the colours of the jumper leads may needed to be changed but that is not a problem. 

I used Raspbian OS and when power up with a power lead (it needs to output enough current to power both devices) both the Pi and screen came on without any difficulty.  

The touchscreen worked well as a mouse and the single power lead makes the system much more compact.


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.

Sunday 17 January 2016

Raspberry Pi - Python Junkbot



Junkbots (http://junkbots.blogspot.co.uk/) are based around using  materials such as drink's cans, broken propellors and motors to produce something that moves by vibration. Previous designs be found at:



The latest tweak to the Raspberry Pi based Junkbot design is to use the combination of Python and Pimoroni's Explorer HAT PRO to control it. Explorer HAT Pro is a good choice, it can control two motors with a library provided to simplify the programming. For this the Junkbot was the one shown above: a drinks can, pen, LEGO bits, motor and broken propellor.

Before the Explorer HAT can be used the library needs to be installed via the Terminal and the instructions below

curl get.pimoroni.com/explorerhat | bash

Python code to control the junkbot is shown below.


import explorerhat
from time import sleep

def spin1(duration):
    explorerhat.motor.one.forward(100)
    sleep(duration)
    explorerhat.motor.one.stop()

def spin2(duration):
    explorerhat.motor.one.backward(100)
    sleep(duration)
    explorerhat.motor.one.stop()

spin1(1)
spin2(1)

Essentially the code spins the junkbot one way and then the other.





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.

Top posts on this blog in March 2024

The Top 10 viewed post on this blog in March 2024. Covering areas such as small robots, augmented reality, Scratch programming, robots. Micr...