Showing posts with label UFO. Show all posts
Showing posts with label UFO. Show all posts

Sunday 25 September 2016

UFO talks to Robot - part one

In previous posts (UFO has Landed and DIMM the OOD),  I started playing with the CBiSEducation's UFO consumable robots. Still using the Micro:Bit, in this two part post series, I am going to be playing with using Micropython to send messages between the two kits.






Stage 1 Wiring and Set up-UFO
Pins 0 and 1 are outputs to the LEDs
The black leads on the UFO go to GND.

Micropython, using the Micro:Bit's built in radio module (Bluetooth), is used to communication between the two kits.



Stage 2 Code -UFO
The code is set to flash the UFO's LEDs and then scroll a message "DIMM Calling" when it receives a message "dimm" via Bluetooth. 

Basic overview is
- Turn on the radio module - radio.on()
- If the message is received then turn the LEDs on and off and scrolls "DIMM calling" across the LED array.
- send a message via bluetooth "ufo" to whoever is listening (in the end the robot DIMM hopefully). The code is shown below. 

import radio
from microbit import pin0, pin1, display, sleep

def pulseLed1(duration):
   pin1.write_digital(0)
   pin0.write_digital(1)
   sleep(duration)
   
def pulseLed2(duration):
   pin1.write_digital(1)
   pin0.write_digital(0)
   sleep(duration)
   
def stopIt():
   pin0.write_digital(0)
   pin1.write_digital(0)

radio.on()

while True:
   incoming = radio.receive()
   stopIt()
   if incoming == 'dimm':   
      pulseLed1(1000)
      pulseLed2(1000)
      stopIt()
      radio.send("ufo")
      display.scroll("DIMM calling")

To use the radio module you will need to switch to the mu editor (http://codewith.mu/).




Stage 3 Testing it
To test it, a second Micro:bit was used to send test signals (the code for this is shown below). When button A is pressed on the second Micro:Bit a message 'dimm' is sent followed by sending 'not'.

import radio
from microbit import button_a, button_b, sleep

radio.on()

while True:
   if button_a.is_pressed():
       radio.send('dimm')
       radio.send('not')
       
   if button_b.is_pressed():
       radio.send('ufo')
       radio.send('not')


The UFO does cycle through the sequence LEDs flash and the message scrolls. The slight bug is in repeats it several times before it stops; possibly a buffering issue somewhere.




Stage 4 
In the next post (http://bit.ly/2d3zlh0), I will be building the Robot DIMM part of the system - sending and receiving message and detecting light levels in micropython.







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 29 August 2016

UFO detects light

In a previous post (UFO has Landed)  I started playing with the CBiSEducation's UFO Consumable Robotics. Now I am going to play with it a bit more and add the light sensor, included in the kit, to it;is so it can detect different light levels. Again it is controlled using the Micro:Bit.

Stage 1 - Decorating it
The kit comes with some stickers so I added a few.

Stage 2 Wiring
Pins 0 and 1 are outputs to the LEDs
Pin 2 is the input from the light sensor
The red lead from the light sensor connects to 3v and the grounds to the ground.


Stage 3 Code

The light sensor works more as a low light level detector, the darker the higher the value returned (in this case) on pin 2. So in low light level,  the LEDs flash relatively quickly, when the light level rises half of the LEDs start to pulse more slowly.






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.

Tuesday 23 August 2016

UFO has landed

CBiS Education generously sent me two of their new range of robotics development kits - BinaryBots (https://www.binarybots.co.uk/makers.aspx), these are a range of cardboard based kits (so far a robot and a UFO) with electronic components for example LEDs; sensors and buzzers,  depending on the kits. What makes the kits interesting though is they are designed to be controlled by either by a BBC Micro:bit or a CodeBug.

This blog documents, briefly, an initial play with the UFO kit (see below) using a Micro:Bit for control. 


The UFO model came together readily, the instructions were fairly easy to follow. Personally, a feature I especially liked about the model was the LEDs being both on the top and bottom of it - increasing its usefulness. CBiS EducationThey have also provided a webpage / portal with some example projects and code. 




My first project I built, was to pulse the LEDs on and off (one set of LEDs on Pin 0, the other on Pin 1). Pin 2 was connected to the buzzer, so produce a low buzz every few seconds. The code below is written using the Block Editor (https://www.microbit.co.uk/create-code)

The video below shows the LEDs pulsing. I do need to decorate the UFO though!




Looking forward to playing with it further.

Related
http://robotsandphysicalcomputing.blogspot.co.uk/2016/08/ufo-detects-light.html


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