Friday, 6 December 2013

 Bluetooth Connection in Android from Matt Bell's blog

Project Structure

Here is the java and xml code from Matt Bell's blog adapted to send data only:


package here
imports here

public class BluetoothTest extends Activity
    TextView myLabel;
    EditText myTextbox;
    BluetoothAdapter mBluetoothAdapter;
    BluetoothSocket mmSocket;
    BluetoothDevice mmDevice;
    OutputStream mmOutputStream;

    public void onCreate(Bundle savedInstanceState)
        setContentView(R.layout.activity_main); // need a activity_main layout XML file
// with these objects below in it (buttons, labels etc...):
        Button openButton = (Button) findViewById(;
        Button sendButton = (Button) findViewById(;
        Button closeButton = (Button) findViewById(;
        myLabel = (TextView) findViewById(;
        myTextbox = (EditText) findViewById(;

        // Open BT connection Button
        openButton.setOnClickListener(new View.OnClickListener()
            public void onClick(View v)
                } catch (IOException ex)

        // Send Button
        sendButton.setOnClickListener(new View.OnClickListener()
            public void onClick(View v)
                } catch (IOException ex)

        // Close button
        closeButton.setOnClickListener(new View.OnClickListener()
            public void onClick(View v)
                } catch (IOException ex)

    void findBT()
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mBluetoothAdapter == null)
            myLabel.setText("No bluetooth adapter available");

        if (!mBluetoothAdapter.isEnabled())
            Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBluetooth, 0);

        Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
        if (pairedDevices.size() > 0)
            for (BluetoothDevice device : pairedDevices)
                if (device.getName().equals("linvor"))// change accordingly
                    mmDevice = device;
        myLabel.setText("Bluetooth Device Found");

    void openBT() throws IOException
        UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");                                                                                                                                                         

if (mmDevice != null) 
            mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid);
            mmOutputStream = mmSocket.getOutputStream();           

        myLabel.setText("Bluetooth Opened");


    void sendData() throws IOException
        String msg = myTextbox.getText().toString();
        msg += "\n";
        myLabel.setText("Data Sent");

    void closeBT() throws IOException
        myLabel.setText("Bluetooth Closed");
}// end of java code.

XML code: 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
      package="your package"
    <application android:label="@string/app_name" >
        <activity android:name="BluetoothTest"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
    <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="9"/>
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <supports-screens android:anyDensity="true" />


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
        android:text="Type here:"/>
        android:text="Open" />
        android:text="Send" />
        android:text="Close" />

Arduino Test Code:
#include <SoftwareSerial.h>

int bluetoothTx = 2;
int bluetoothRx = 3;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
const int LED = 10;
char incomingByte = ' ';

void setup()
  //Setup usb serial connection to computer
  pinMode(LED, OUTPUT);
  //Setup Bluetooth serial connection to android

void loop()

  //Read from bluetooth and write to usb serial
    Serial.println("BlueTooth OK");
    char toSend = (char);
    incomingByte = toSend;

if (incomingByte == 'l')
digitalWrite(LED, HIGH);
digitalWrite(LED, LOW);

[end code]----------------------------------------------

Friday, 11 October 2013

FrankenTech Case Hack

Motorola micro TAC from 1995


I have a 1995 Motorola micro TAC mobile phone. I'm am going to FrankenTech it by putting in a modern GSM party phone. I will have to lose the retro keypad to keep the functionality of the party phone. I think I will need to keep the speaker too -not sure at this stage. So don't rush in and cut the speaker out!

It is just a case hack, but I always liked the look and feel of that old phone. Somewhat Treky (flip cover) and military looking (antenna). The party phone VX1 was £10 from Tesco, Text and voice only.

Ideally I would love to use the Motorola as is, but there is no way to use it with a SIM. It will also  be chargeable via USB. Resistance is futile - you will be assimilated!

Here are the parts:

It should turn out something like this artist's impression:


As with all cutting of cases and plastic boxes, to make a neat job, it's about patience and having good tools. I used these:
  • a very sharp sturdy craft knife (these are often called Stanley knives in the UK).
  • a jewellery-type piercing saw
  • a cutting board
  • a set of needle files
  • craft drill and toolset
  • small jeweller's round nose pliers
  • side cutters
Opening the case
 There are no screws on this case. It is all moulded plastic with lugs that hold it together. That makes it tricky to open without damage. I used the small round nose pliers to push aside the lugs.

 Case already open showing lugs and slots.

  • first remove the battery on the back
  •  locate the four slots with lugs
  • as gently as you can use a tool (I used small round nose pliers) to push the lugs towards the outside of the case. This should pop them out of place and allow partial opening, with each lug popped in turn.
  • remove the back
  • carefully remove all of the innards of the phone, but leave the speaker inside with the wires attached (cut wires close to circuit board)
Dissection of the case body
to follow........

Wednesday, 21 August 2013

Whistle and Wag!

 Detect sound generated by

 Buccal Wetware

 [brain; purse lips; exhale; whistle]

A very simple and Fun Hack for Whistle and Find Device

This is a fun hack for those whistle and find devices. The type you attach to your remote control so you can always find it eg whistle and find device.

That ones quite expensive, but you can often find them on offer in bargain shops for a couple of quid. I bought a set years ago and had one left rattling around in one of my junk drawers. I decided to play with it because I was looking for a way to add an interactive waggy-tail to a small robot.

You also need a small servo, arduino (or similar) a photo-resistor and a 10K pull down resistor - simple!

Whistle-n-Wag Circuit

Place the led of the device right next to the sensor surface of the photo-resistor and shade it.
When you whistle the device flashes it's led and that light is picked up by the photo-resistor, this makes a circuit with the 5v supply and this voltage is detected by the analogue pin of the arduino. The video is not good quality but you can get the gist. NB you can use the whistle hardware provided with the sets, but notice I used buccal wetware to generate the sound in the video [brain->purse-lips->exhale = whistle] : )

Whistle-n-Wag Video

Arduino Code:
Servo myservo;
int wag = 0;
int pos;
//PhotoResistor Pin
int lightPin = 0;

int servopin = 7;   //the pin the servo is connected to
void setup()
  pinMode(servopin, OUTPUT); //sets the servo pin to output
  digitalWrite(servopin, LOW);  //servo OFF

void loop()
 int lightLevel = analogRead(lightPin); //Read the
                                        // lightlevel

if (lightLevel > 450)
   wag = 1;

 if (wag == 1)

   for (pos = 0; pos < 180 ; pos +=2)




Friday, 9 August 2013

Positronic Brain Sim requires no MCU?

A Diamond Flashing LEDs Update II

Christmas lights, Halloween, Mood Light, Baby Light

This is a screen-shot of the positronic-brain-sim PCB design [R = red, G = green, A = amber P = pink] The LEDs are diamond cut flashing leds available here: Rapid [UK]

The design is copyright of Craig Turner 2012, 2013. But feel free to make some PCBs for personal use and enjoy them. No PCB copies should be made for sale or any commercial use.

This could be a costume Idea for Halloween (I plan to put them in a model of a human head), Christmas lights, a mood light, baby lights or any other cool lighting idea application. It's so simple, and works on the principle that each colour has differnt power requirements hence no MCU is required. It reminded me of a positronic brain you might find inside an android. See here for more details of  How it works. 

NB that LED D18 is in fact Green and not Yellow. It was mistakenly shown as yellow in an earlier post.

Here is the circuit diagram again in it's simplest form. As you can see it's just a grid of these special LEDs with a power supply (eg USB) and a switch. It runs quite happily and brightly off 5v so a USB is perfect.

I'm looking into getting some PCBs made of this simple design so I can easily share it with friends and family, the Scouts and anyone else, for that matter. Here is the art work in .jpg format if you want to etch one yourself, on my Google Drive.

See comment on Hackaday

Friday, 2 August 2013

Positronic Brain Sim requires no MCU?

Costume Idea for Halloween

A Diamond Flashing LEDs Update I

D1 to D35 are diamond flashing LEDs. D36 and D37 are multicolor cycling LEDs. 

Just a quick update to the diamond flashing LEDs. I hacked a USB cable and attached this as the power source. I also added some two lead colour-cycling LEDs (not shown on video).

A bit of fun and very pretty. It might be good as a baby mobile or a calming mood light - it's quite relaxing and almost hypnotic. I decided to make it as a "pick-me-up project" for those long winter nights in 2012.  I'm now looking to use this idea to look like a positronic brain for halloween 2013 [positronic brain] inside a model of a human head.

The video speaks for itself. A very simple circuit with no MCU - the arrangement of led's makes the flashing pattern. I think it's the slightly different power requirements of the different colours that makes the pattern work.

I reasoned that blue and green need more power before they switch on, so red goes first. The red and yellow ones are last to go off as I gradually drop the power using a variable PSU.

Slowed down the video shows that red and yellow come on first before the pattern stabilizes. I'm not sure if this explanation of the pattern is correct. Please comment if you agree or not, or have any more ideas.

The design is copyright of Craig Turner 2012, 2013. But feel free to make some PCBs for personal use and enjoy them. No PCB copies should be made for sale or any commercial use.

You can get the led's here:

Saturday, 22 June 2013

Earth Rover 

Part IV

Android / Arduino Interface Code Update.

Code update for android and arduino files. Note xml files are added on to end of Java code in same file to save space. You will need to cut and paste them to the correct xml files.On my google drive:

The update incorporates two way serial comms over BT. RC control from Android with bumper sensors controlling interrupts to stop the Rover and display which bumper was triggered on the display. Note I am using button action:  if (event.getAction() == MotionEvent.ACTION_MOVE)
which means you have to keep you finger or stylus moving slightly to keep sending the signal. A small safety feature.

It is an update but it isn't working fully. The interrupts are triggered incorrectly by the movement of the robot's motors. I am working towards finding out why and a solution. Please let me know if you have some ideas.

Monday, 17 June 2013

Father's Day

My Dad, Jack Turner Born 1936 
He was the first person in our family history to get a decent education, thanks to his working class parents who struggled in impossible times to get him there.
He volunteered for the RAF as a firefighter, during the years when National Service was compulsory. He served 25 years in the W. Yorkshire Fire Service and saved many lives, nearly copping it himself a couple of times. 
It's thanks to him I became a scientist and a geek. He bought me a chemistry set when I was five and taught me about how chemicals can interact to make fire and fire-hazards. To me, at that age, means fireworks. He let me have a lab in our attic and bought me more chemistry sets, a microscope, electronics kits and other cool science stuff.
 Thanks Dad for being a great Dad, a hero, and an inspiration.
 Craig Turner [gampa geek]