Skip to main content

Posts

Showing posts with the label python

Top 10 viewed posts 2021 on the Robot and Physical Computing Blog

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 , tha... PS3 Controller to move a USB Robot Arm Guest Blogger Hiren Mistry, Nuffield Research Placement Student working at the University of Northampton. How to use a PS3 Controller to... Scratch Robot Arm It is not physical but CBiS Education have release a free robot arm simulator for Scratch.  Downloadable from their site  http://w... Tinkercad and Microbit: To make a neuron The free online CAD (and so much more) package Tinkercad  https://www.tinkercad.com/ under circuits; now has microbits as part of the list ... 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 simula... Easy, Free and no markers Augmented Reality - location based AR For a few years...

Hug Avoider 4 - micropython, Eggbot and speech

The last of the posts on the Hug avoider and the 4Tronix's Eggbit 4Tronix's Eggbit (in fact I bought three of them  https://shop.4tronix.co.uk/collections/bbc-micro-bit/products/eggbit-three-pack-special   :-) recently) is a cute add-on for the microbit. In three previous posts I looked at eggbit using microcode to  produce a hug avoider - warns when people at too close. - https://robotsandphysicalcomputing.blogspot.com/2021/12/hug-avoider-2-4tronix-eggbit.html -  4tronix Eggbit - cute and wearable - hug avoider Hug Avoider 3 - experiments with Python and 4Tronix Eggbit In this post using the buttons and adding (via Microbit V2 with its speaker) simple speech 1. Buttons Pins for the buttons pin8 - Green button pin12 - Red button pin14 - Yellow button pin`6 - Blue button     if pin12.read_digital()==1:         #Red Button         blank_it()     if pin8.read_digital()==1:         #Green but...

Hug Avoider 3 - experiments with Python and 4Tronix Eggbit

via GIPHY 4Tronix's Eggbit (in fact I bought three of them  https://shop.4tronix.co.uk/collections/bbc-micro-bit/products/eggbit-three-pack-special   :-) recently) is a cute add-on for the microbit (see above).  In two previous posts I looked at eggbit using microcode to  produce a hug avoider - warns when people at too close. - https://robotsandphysicalcomputing.blogspot.com/2021/12/hug-avoider-2-4tronix-eggbit.html -  4tronix Eggbit - cute and wearable - hug avoider This post replicates  some of this, but this time using Python and shows the stages of the build Get the ultrasound to find the distance; Produce smile and surprise on the eggbit's 'mouth'; Produce rainbow on the neopixels or all the pixels turning red; Bring it all together so if the person is too close, less than 30cm it reacts.   1. Ultrasonic detection Probably the most challenging bit of this was getting the ultrasonic distance measrement working. It actually is not that difficult; e...

Microbit and Environment Measurement - Using Python

In two recent posts, Makecode was used with the Enviro:bit from Pimoroni to try out a few ideas ( https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit.html  and   https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit-light-and-led.html ). In this post Pyton using the Mu editor was used to try out the Enviro:bit. As in the makeCode version, Pimoroni has provided both a python library (via Github) but also within the Readme.md useful installation instructions. There is at the time of writing a possible typo; to get the BME280 sensor (temperature, pressure, humidity sensor) to work; you need to add parenthesis in the line  bme = bme280.bme280() After that, it works fine and includes potential altitude measurement which I don't think is in the Makecode version (though I could be wrong); I need to play with it a bit more. To experiment the code below was used test reading temperature (in Centigrade), humidity (%), and altitude (f...

Initial experiments with Code Bug Connect

Code Bug has been around for a while, and it is incredibly cute, When it first came, it was a very interesting piece of kit - and it is still is and fun to play with. It spec means it is still a very useful piece of kit. 5x5 Red LED display 2 buttons 6 touch sensitive I/O pads (4 input/output, power and ground) Micro USB socket CR2032 battery holder Expansion port for I2C, SPI and UART Blockly-based online programming interface CodeBug emulator for checking code before downloading In 2020 Code Bug launched and successfully funded a Kickstarter campaign ( https://www.kickstarter.com/projects/codebug/codebug-connect-cute-colourful-and-programmable-iot-wearable ) for a new version the Code Bug - CodeBug Connect with a serious upgrade.(and the name Connect is highly appropriate with USB tethering and Wifi capability in this version. The technical specification (taken from their site https://www.kickstarter.com/projects/codebug/codebug-connect-cute-colourful-and-programmable-iot-wearable ...

VR robot in a maze - from Blocks to Python

Recently I produced a post about playing with Vex Robotics VexCode VR blocks and the Maze Playground. The post finished with me saying I would like to play with Python and do a Python version of it. Well it is actually very easy to do it. You can do it in two stages from the block code. First click on the <> icon (lighted in the figure above and it gives a further view producing Python code that changes as you change the blocks. The last stage is to convert to a text project (button at the bottom right of the screen. Example of the code. myVariable = 0 def when_started1(): global myVariable drivetrain . drive_for ( FORWARD , 100 , MM ) while not down_eye . detect ( RED ): drivetrain . drive_for ( FORWARD , 5 , MM ) if right_bumper . pressed (): drivetrain . drive_for ( REVERSE , 30 , MM ) drivetrain . turn_for ( LEFT , 20 , DEGREES ) drivetrain . drive_for ( FORWARD , 20 , MM ) else : if l...

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 ...

Build a Disco cube:bit that reacts to music.

In a previous post Micro:bit and Cube:bit 'says' Hello  I introduced the start of me playing with the  4tronix Cube:bit . One of the things I want to try is get the cube to react to music, based around the accelerometers in a micro:bit picking up vibrations.  Luckily, in an earlier post, I had done something similar for the  Proto-Pic Micro:pixel  (see  Dancing Pixels  for more details).  Essentially the idea is  the vibrations from the music shake the micro:bit enough to give measurable changes in three axis, and these values are used to change the pixel's colour - in fact five pixels at a time. The code shown below is all that was needed: from microbit import * import neopixel, random np = neopixel.NeoPixel(pin0, 125) while True:     for pxl in range (2,125, 5):         rd=int(abs(accelerometer.get_x())/20)         gr=int(abs(accelerometer.get_y())/20)   ...

Getting Crabby with EduBlock for Microbit

This is really pulling together two recent posts, one when I started playing with Edublocks for the microbit  and one about playing with BinaryBots Crab  . The BinaryBots Totem Crab is available at  https://www.binarybots.co.uk/crab.aspx Here I going to use Edublocks ( https://microbit.edublocks.org/ ) by @all_about_code to control the claw of the Crab to close when button A is pressed (and display a C on the LEDs)  and open the claw when button B is pressed. For a discussion on the Crab and what the pins are, etc goto  http://robotsandphysicalcomputing.blogspot.com/2018/08/crabby-but-fun.html  for more details.  The timing of the opening and closing is controlled by how long the C or O takes to scroll across the LEDs. As an aside, but I found it interesting (it appeals to my geekiness), if you save the blocks, using the Save button; it stores it as an XML file, an example extract is shown below: Now I want to exp...