Sunday, April 6, 2014

HC-06 Bluetooth Slave Only

I bought a Bluetooth adaptor from eBay a while back and configured it allow me to login to the Raspberry Pi over Bluetooth.
As part of this I changed some of the settings on the adaptor and like a proper hacker didn't write down the changes anywhere and then lost my code when the Raspberry Pi SD got corrupted and I installed Lubuntu on my netbook (was XP).

After doing a lot of searching online I found details for the HC-05 and how to reset it by setting the Key pin HIGH and putting it into command mode.

After about 5 hours of messing with the adaptor and even noting the Key breadboard pin wasn't connect to the Key pin on the board, so shorted the pads on the back of the board. Then desoldered again

Nothing worked.

Then checked if what I really had was a HC-06. The Slave only version of the HC-05 board and guess what it is an HC-06 board and so the Key HIGH method doesn't work.

Note the little transistor near the header
Haven't seen this on any of the HC-05 modules
Also, on the back of the board there are 2 sets of pads not populated.

But from reading the following Google DOC (https://docs.google.com/document/d/1GPVqL9jlnIKFUL0lRGdRNrYFvxKRR-yjNSRYhlr1j84/edit) discovered you can reset the HC-06 by setting PIN 11 to LOW on the module.
I did this, cycled the power and now I could connect at 9600.  All good.

I downloaded the Sketch from here: http://www.plastibots.com/index.php/2013/12/31/hc-06-bluetooth-module-getting-this-sucker-into-at-command-mode/
And it worked.

So, no Master mode (cannot initiate pairing) but it's now working so I can have some proper fun with it.

Sunday, February 23, 2014

Arduino Compatible robot for £15

I was looking for a low cost way of building a vehicle controlled by an Arduino or Raspberry Pi and eBay once again came up with the solutions.

1 x Smart Robot Car Chassis Kit  - £7.60
1 x L298N - £1.86
1 x Arduino Compatible Pro Mini - £2.53

Total Cost: £11.99

The Smart Robot Chassis comes with 2 motors and wheels.  It comes with the encoding wheels for optical encoder to measure rotation, but without the electronics.
All the parts with chassis. 


The L298N is a Motor Driver Module
That's it on the right next to the battery pack


While the Pro Mini is a small Arduino compatible board that I previously blogged about programming (http://winkleink.blogspot.co.uk/2014/01/programming-arduino-pro-mini-16mhz-5v.html) and soldering the headers (http://winkleink.blogspot.co.uk/2014/01/soldering-up-pro-mini-arduino.html)

You need a USB to serial adaptor to program it. For this adaptor you have to solder a pin to the DTR and then attach that to the RST line on the Pro Mini when programming.

I built the Chassis and attached the L298N
All the parts

Bits for the front wheel mounting
Screw the spacers to the chassis


Attach the swivel wheel to the spacers.
Note nuts not in original picture

Parts for motor/wheel mount

Use small screws to attach pillars to chassis

Parts for connecting motors

Screw motor to the outside of the pillars.
Note: make sure to have motor connectors on the inside
for easy cable management

Add the encoder wheels if you want and the actual wheels

See in front of batter holder are the two holes where
the battery holder will be bolted to.
Use 2 of the slightly longer bolts for this.

All finished.  Still needed to solder the wires to the motors.


The L298N is then wired.

+ Battery to VCC and 5V on the L298Nand RAW on the Pro Mini. The L298N appears to be OK with 6V going to the 5V line. And the Pro Mini doesn't complain about the 6V from the batteries either.
As always connect all the GNDs together

Then for each motor connect Out1 and Out2 to one Motor and Out3 and Out4 to the other motor. Depending on which way around you do the connection will decide which way the motors spins, so if this is wrong you can either swap the wires or modify the code.

Then for control from the Pro Mini I connected

IN1 to 3
IN2 to 5
IN3 to 9
IN4 to 10

The eagle eyed will have noticed these are 4 of the PWM lines so in the future I can enable speed control by driving using PWM rather than digital.


Uploaded the following Sketch tot he Pro Mini and let it rip - see video at the bottom

// motor driver using PWM

int lb = 3;
int lf = 5;
int rb = 10;
int rf = 9;


void setup() {
  // put your setup code here, to run once:

  pinMode(lb, OUTPUT); 
  pinMode(lf, OUTPUT); 
  pinMode(rb, OUTPUT); 
  pinMode(rf, OUTPUT); 
  
  digitalWrite (lb, LOW);
  digitalWrite (lf, LOW);
  digitalWrite (rb, LOW);
  digitalWrite (rf, LOW);

}

void loop() {
  // put your main code here, to run repeatedly: 
  
    digitalWrite (lf, HIGH);
    digitalWrite (lb, LOW);
    digitalWrite (rf, HIGH);
    digitalWrite (rb, LOW);

    delay(1000);

    digitalWrite (lf, LOW);
    digitalWrite (lb, LOW);
    digitalWrite (rf, LOW);
    digitalWrite (rb, LOW);

    delay(1000);

    digitalWrite (lf, LOW);
    digitalWrite (lb, HIGH);
    digitalWrite (rf, HIGH);
    digitalWrite (rb, LOW);

    delay(600);

    digitalWrite (lf, HIGH);
    digitalWrite (lb, LOW);
    digitalWrite (rf, HIGH);
    digitalWrite (rb, LOW);

    delay(1000);

    digitalWrite (lf, HIGH);
    digitalWrite (lb, LOW);
    digitalWrite (rf, LOW);
    digitalWrite (rb, HIGH);

    delay(600);
}



All worked well.
Next I need to put in place a way of controlling it remotely.
The adventure continues.

Note: This chassis and L298N should also work with a Raspberry Pi. Need to be more careful with the power and a few other bits. 


Wednesday, January 22, 2014

16x16 LED Matrix using MAX7219 from eBay for Arduino


Like a lot of people one of the first things I did with my Arduino was use it control an 8x8 LED Matrix and then get it to do fun things like scrolling messages and making little games. It's amazing what you can do inn 8x8.

Arduino Scrolling Message changed using Serial Monitor



Arduino 8x8 LED Racing Game

But going beyond 8x8 is not as easy as it seems due to trying to get the boards aligned and also just the sheer number of wires needed to connect all the driver ICs. From the video above for the Race Game you see there are a lot of wires just for an 8x8 if using a 74HC595 .

On one of my semi-regular trawl of eBay I came across the following.


It's 4 separate 8x8 LED modules with the MAX7219 driver IC included.  No great shakes there as these are all over eBay and anywhere else you want to buy electronics bits.
The difference is the last word in the description 'Cascade'  In the images and short video at the link they are shown in an 16x16 arrangement and if you look closely at the boards there are extra headers in each corner to facilitate the cascading.

Of course I had to buy a set which I'm waiting to be delivered. Slow boat from China. Could be a fun March when it arrives.