Showing posts with label rainbow. Show all posts
Showing posts with label rainbow. Show all posts

Monday, 7 August 2017

kitronik :Move mini buggy (Python control of LEDs)

In two previous posts I looked at control the :Move buggy using JavaScript Blocks or Python. In this post we are going to look at controlling the LEDs using Python (or more accurately micropython).

Pin 0 controls the LEDs, they are based on5  NeoPixel compatible, RGB, addressable LEDs; so the Neopixel protocols (and library for Neopixels) can be used. 



Code First five colours of the rainbow. The array lig holds the RGB settings for the rainbow colours (more details on the RGB colours can be found at Lorraine Underwood's Halloween Cloud project). In the code below, the five LEDs have a different colour allocated to them.

from microbit import *
import neopixel

np = neopixel.NeoPixel(pin0, 5)
lig=[[255,0,0],[255,127,0],[255,255,0],[0,255,0],[0,0,255],[75,0,136],[139,0,255]]
while True:
    np[0] = lig[0]
    np[1] = lig[1]
    np[2] = lig[2]
    np[3] = lig[3]
    np[4] = lig[4]

    np.show()


Code to cycle through the rainbow
from microbit import *
import neopixel

np = neopixel.NeoPixel(pin0, 5)
lig=[[255,0,0],[255,127,0],[255,255,0],[0,255,0],[0,0,255],[75,0,136],[139,0,255]]
count1=1
count0=0
count2=2
count3=3
count4=4
while True:
        np[0] = lig[count0]
        if count0>=6:
            count0=0;
        else:
            count0=count0+1
        np[1] = lig[count1]
        if count1>=6:
            count1=0;
        else:
            count1=count1+1
        np[2] = lig[count2]
        if count2>=6:
            count2=0;
        else:
            count2=count2+1
        np[3] = lig[count3]
        if count3>=6:
            count3=0;
        else:
            count3=count3+1
        np[4] = lig[count4]
        if count4>=6:
            count4=0;
        else:
            count4=count4+1
        np.show()

        sleep(500)


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

Sunday, 20 March 2016

Playing with Ozobot Bit and Blockly

Previously I discussed the older Ozobot that were programmed by colours on paper or made to dance via an App. The newer Ozobot Bit still can be used in these ways but also can be programmed using a Blockly web-based interface at http://ozoblockly.com/editor, so are now programmable on tablets, but also PC, Macs, essentially anything that can run the webpage.



First stage is the calibration of the 'bot'
1. Hold the power button on the ozobot until it starts flashing with a white light.
2. Move to the white space that is similar to the bottom of the Ozobot, the wheels might start moving but as you get closer to the space they should stop.
3. The Ozobot should start flashing green - that is ok continue holding the ozobot to the screen until it stops flashing green - if it flashes red start again.





Build your code blocks and when you are ready press the power button on the Ozobot. Hold the ozobot against the white space again and holding it there press the load button. The white space should now be flashing different colours, but the ozobot should be flashing green programming the ozobot.



Now to run them press the power button twice. I have add a two second delay in the code so I can get my hands out of the way before they start moving. The video below shows two of them so through this routine twice
- 2 second delay;
- Zigzag a little
- Flash the lights through the rainbow colours;
- Move in an arc;
- Flash the lights a bit like fireworks going off



It is relatively easy to program these and fun, but you may have to hold the Ozobot to the screen for a while if you use a Mac or PC. They are cute and the flashing LEDs offers some interesting effects like the 'fireworks'.


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.

Who wants to produce AI produced cartoon strips

Question: How easy is it produce a comic/cartoon using genetative AI? Let's start with  using ChatGPT4o to produce cartoons. The idea wa...