Tuesday 23 April 2019

Combining Beta Edublocks and Microbit Playground

I have recently been playing with Edublocks (edublocks.org) and the 4tronix's Microbit Playground (the appropriately named Super Kit) controlling programmable pixels/neopixels  and a servo.





Recently a beta version of the Edublocks (see above) has become available (https://app.edublocks.org/) so I wanted to play with it a bit and, at the same time, combine control the servo motor and neopixels together via a potentiometer (see below).





The block version of the code is shown below:




The python version
np = None
port1 = None
pot2 = None
port3 = None


from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0, 8)
pin2.set_analog_period(20)# your own code
while True:
  port1 = pin1.read_analog()
  pot2 = port1//128
  port3 = port1//8
  np[pot2] = (255, 0, 128)
  np.show()
  pin2.write_analog(port3)
  sleep(250)
  np.clear()

To see it action



via GIPHY


A few thoughts on the beta version, I actually like it more than the current version for doing this kind of activity. I found it clearer to use,  it was easier to know what was needed to be done with blocks around the neopixels than the previous version, which needed a little more thought.







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

Tuesday 16 April 2019

microbit playground and Edublocks: Controlling the servo

Using the brilliant Edublocks specifically to microbit (https://microbit.edublocks.org/ ) I have been playing with a 4tronix Microbit playground. Previously I played with getting the turning a potentiometer to selected which neopixel light up, in this post the potentiometer is used to control the direction of the servo motor.

Below is the block code in Edublocks used to do this.


Set up use the Potentiometer attached to Pin1 to control the direction of a servo motor on pin2. 

The potentiometer output is turned into values between 0 (or 5 when I checked) and 1023; it is then divided, using the Floor operation (//, returns the integer part of a division), by 8 to decrease the sensitivity of turning the potentiometer. These values allow both clockwise and anticlockwise turning of the servo to based on the full range of the potentiometer. The line pin2.set_analog_period(20) was based on experimentation in a previous post.

The text-based version of the python code is shown below

np = None
pot1 = None
pot2 = None


from microbit import *
pin2.set_analog_period(20)
while True:
  pot1 = pin1.read_analog()
  pot2 = pot1//8
  pin2.write_analog(pot2)



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

microbit playground and Edublocks: Controlling the pixels

Using the brilliant Edublocks specifically to microbit (https://microbit.edublocks.org/ ) I have been playing with a 4tronix Microbit playground








Set up use the Potentiometer attached to Pin1 to select which of eight neopixels is turned on.

The potentiometer output is turned into values between 0 (or 5 when I checked) and 1023; it is then divided, using the Floor operation (//, returns the integer part of a division), by 128 to give a number between 0 and 7. This number is used to selected which pixel attached to pin 0 lights up. Each pixel is set to white.

The text-based version of the python code is shown below
np = None
pot1 = None
pot2 = None

from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0, 8)
while True:
  pot1 = pin1.read_analog()
  pot2=pot1//128
  np[pot2] = (32,32,32)
  np.show()
  sleep(50)
  np.clear()

via GIPHY

It is going to be interesting to explore both a bit more.







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

ChatGPT, Data Scientist - fitting it a bit

This is a second post about using ChatGPT to do some data analysis. In the first looked at using it to some basic statistics  https://robots...