While my printer churns away on the parts for the two track systems (80 hours and counting) I decided to complete the remote. As detailed in a previous post this is based on the Wii Nunchuk and sends data to Wall-E over Bluetooth. I wanted to keep the whole remote control as compact and unobtrusive as possible. The idea behind this is to allow Wall-E to appear independent when on show but actually being controlled from a distance.

Wii Complete

To ensure the compact nature of the remote everything had to be contained inside. This meant I had to choose parts that are extreamly small as the space is limited. I used an Ardunio Pro Mini as the micro controller with the intention that if I couldn't make everything fit it would be possible to go down to an ATTiny.

ProMini3v3

The Pro mini used is the 3.3v version since the Wii nunchuk required 3.3v to run (but will run on 5v if required) and the Bluetooth (ZS-040) uses 3.3v on the it's data lines. As the Pro Mini contains a voltage regulator to drop the voltage to 3.3v and the bluetooth requires at least 3.6v I also had to add a step up voltage converter to take the battery voltage (3.1-4.2v) to 5v and provide regulation. This 5v is then fed to both the Ardunio (RAW pin) and the Bluetooth module.

dcdc boostbluetooth zs 040

I made a 'fritzing' of the circuit for better demonstration.

Wii Circuit

In this circuit the brown board represents the internal board of the Wii Nunchuk I purchased from ebay (chinese clone). This board is connected to the 3.3v and GND output of the Pro Mini for power and to the A4 & A5 pins for the I2C data bus. Both the Pro Mini and the Bluetooth (ZS-040) module receive a 5v power supply from the red board which is a step up transformer taking the 3.7v battery to 5v. A switch is provided to turn the electronics on and off and a JST connector (the red block) it connect the battery up to a standard 4-button charger.

It should be notied that the LiPo chosen for this project contains a battery protection circuit so I have not included battery protection elsewhere in the design.

In reality this looks far more like spaghetti than the diagram would suggest.

Wii InternalWii Internal2

Getting all this inside the nunchuk casing was a challenge and I had to cut out much of the internal plastic supports to make it fit. The limited space also caused issues with the reset button on the Ardunio being triggered by accident. As this switch is NOT accessible I simply de-soldered it from the board. This also provided a little more space and meant everything finally fits and is working.

Wii Packed

So to the Ardunio code........I borrowed an idea from James Bruton's BB8 v3 build. This can be found in the video below (13:24 onward for the actual idea and code I used) and many thanks to James for the inspiration.

The borrowed part of the code (and the new red LED in the diagram) relate to the bluetooth pairing. The bluetooth module has a pin (STATE) that goes high when the pairing is completed. James wrote some code that allows the controller to monitor this pin and to only send data when the pairing is completed. I have borrowed this small code chunk and LED and put them inside my remote.

Once powered up the Ardunio waits for the bluetooth to pair, once paried it flashs the red LED and starts to take data from the nunchuk inputs and sends them down a software serial port on pins 2 and 3 of the Ardunio to the bluetooth where it is transmitted to Wall-E. The Arduino code doing this is below.


/*
Nunchuk

This sketch provides interface from Wii Nunhuck to Wall-E over bluetooth.
It is intended for an Arduino ProMini (3.3v - 8Mhz) which is embeded in the Nunchuk itself
This is NOT a final version for us on the device but a development version for testing

The circuit:
* Nunchuk attached to I2C lines (A4,A5)
* Bluetooth ZS-040 module configured as master attached to digital D2,D3 for software serial)

Created 1st Feb 2016
By Simon Gutteridge

Modified(s)
- Add pair function from James Bruton (xrobots.co.uk) (09/04/2016 - Simon Gutteridge)

*/

#include <Wire.h>
#include <SoftwareSerial.h>
#include <ArduinoNunchuk.h>

#define BAUDRATE 9600 //Bluetooth BAUD rate
SoftwareSerial BTserial(2,3); //RX|TX for Bluetooth

//Nunchuck data
ArduinoNunchuk nunchuk = ArduinoNunchuk();
char nunData = ' ';
int state = 0;

void setup()
{
//start Nunchuck
nunchuk.init();

//start Bluetooth
BTserial.begin(BAUDRATE);

//set pins
pinMode(5,INPUT); //State line from Bluetooth - high when paired
pinMode(6,OUTPUT); //pairing indicator LED
}

void pair() //function to flash LED while pairing is taking place. LED left on once paired
{
digitalWrite(6, LOW); // turn LED on pin 6 off
while(state == 0)
{
state = digitalRead(5); // check to see when BT is paired
}
digitalWrite(6, HIGH); // turn LED on pin 6 on
delay(200);
digitalWrite(6, LOW); // turn LED on pin 6 off
delay(200);
digitalWrite(6, HIGH); // turn LED on pin 6 on
delay(200);
digitalWrite(6, LOW); // turn LED on pin 6 off
delay(500);
digitalWrite(6, HIGH); // turn LED on pin 6 on
}

void loop()
{
//verify we are still paired with Wall-E
state = digitalRead(5);
if (state == 0)
{
pair(); //goto wait for pairing if not paired
}

//get the data from the nunchuck
nunchuk.update();

//send data
BTserial.print((int)nunchuk.analogX);
BTserial.print(",");
BTserial.print((int)nunchuk.analogY);
BTserial.print(",");
BTserial.print((int)nunchuk.accelX);
BTserial.print(",");
BTserial.print((int)nunchuk.accelY);
BTserial.print(",");
BTserial.print((int)nunchuk.accelZ);
BTserial.print(",");
BTserial.print((int)nunchuk.zButton);
BTserial.print(",");
BTserial.print((int)nunchuk.cButton);
BTserial.print("\n");

}