BTDBtd(&Usb);// You have to create the Bluetooth Dongle instance like so
/* You can create the instance of the class in two ways */
WIIWii(&Btd,PAIR);// This will start an inquiry and then pair with your Wiimote - you only have to do this once
//WII Wii(&Btd); // After the wiimote pairs once with the line of code above, you can simply create the instance like so and re upload and then press any button on the Wiimote
boolprintIR1;
boolprintIR2;
voidsetup(){
Serial.begin(115200);
if(Usb.Init()==-1){
Serial.print(F("\r\nOSC did not start"));
while(1);//halt
}
Serial.print(F("\r\nWiimote Bluetooth Library Started"));
}
voidloop(){
Usb.Task();
if(Wii.wiimoteConnected){
if(Wii.getButtonClick(HOME)){// You can use getButtonPress to see if the button is held down
Serial.print(F("\r\nHOME"));
Wii.disconnect();// Disconnect the Wiimote - it will establish the connection again since the Wiimote automatically reconnects
}
else{
if(Wii.getButtonClick(ONE)){
Wii.IRinitialize();// Run the initialisation sequence
//Wii.statusRequest(); // This function isn't working right now
}
if(Wii.getButtonClick(TWO))// Check status request. Returns if IR is intialized or not (Serial Monitor only)
Wii.statusRequest();// Isn't working proberly. It returns "extension disconnected", will fix soon
if(Wii.getButtonClick(MINUS)){
printIR1=!printIR1;// Will track 1 bright point
printIR2=false;
}
if(Wii.getButtonClick(PLUS)){// Will track 2 brightest points