Why do not buy a Missile Launcher and mod it a little?
You can find "Desktop Defender" toy on ebay.
First of all, you will need to open the control pad. You'll find a 7 pin connector. My idea is to do not break the control pad. I want to add an extra input method to it. So... Let's solder them.
The control pad:
- Closes the circuit between -3V and DO (Down), L (Left)
- Closes the circuit between +3V and UP (Up), R (Right), PLA (Play)
We will need to replicate this on Arduino side.
The issue is... We cannot control a DC Motor directly via Arduino. In this particular case the +3V would be compatible with Arduino (Nano or Pro, for example). The current is the issue. The motors are protected by 2 limit switches for each direction, so they will not stall (the motors reach peak current draw when stalling), but as my "dumb" tester says... There are still 90mA when closing the circuit. Which is more than the maximum allowed for I/O Pins (e.g.: 40 mA).
There are different options for driving DC Motors safely:
- PWM (Pulse-Width Modulation)
- But we do not need to drive speed of the motor... Overkill.
- DC Motor controller (H-Bridge)
- MOSFET, Transistor + Diode (To protect for spikes at on/off time)
- Good solution, cheap... But we must size the Transistor, Resistance correctly
- Good explaination here and here
- Optoisolators
- Details here
- I just discovered them... Amazing! In few words... It allows to drive the current on another circuit using a LED and... A phototransistor on the other side. We can call them also photocouplers.
- Each product has its own maximum voltage and current.
- It is a good choice, cheap, reusable. Available products: optoisolators, opto-isolator shield, etc...
- Relay (and solid state Relay)
- A low current driven mechanical switch. It is a good choice, cheap, reusable.
- In the case of solid state... It is not mechanical... Extended lifetime and faster than common relays.
- Each product has its own max voltage and current.
- Good choice as above. Available products: Solid State Relay, Relay Shield for Grove, etc...
My choices are optoisolators, relays (I found a L293DNE on my magic box, hurray... But I am unable to use it, except if I completely remove original control pad).
Since I will wait for parts to be shipped, see you in few days/weeks!
Ok people... SainSmart come in my help!
I just tested using a single Relay and my Bluetooth Silver Mate.
It works! Here you are the code... I'll deploy everything on github (both Arduino and Android code).
A video and photos in next days...
I just tested using a single Relay and my Bluetooth Silver Mate.
It works! Here you are the code... I'll deploy everything on github (both Arduino and Android code).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
+-------+-------+------+--------+------+-------+--------+ K BLACK | |
| BLACK | WHITE | GREY | PURPLE | BLUE | GREEN | YELLOW | | |
+---+---+--+----+--+---+-+------+--+---+---+---+----+---+ R RED | |
+ + + + + + + | |
| | | | | | | G GREEN | |
+------|-----+-|-----|-+ | | | | |
+-|-----|-|-----|-|-----+-|-----+-+ | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
+ + + + + + + + + + + + + +------+ | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---+-+ | |
|D 4 | D 2 | D 3 | D 1 | C NO | | |
+-----+-------+-------+-------+-------+ +------------------------+ | |
|GND I1 I2 I3 I4 VCC|R K G| |BLUETOOTH MODULE | | |
+-----------------------------+-------+ +------------------------+ | |
| 4 RELAIS MODULE |RELAY M| |RTS RX TX VCC CTS GND | | |
+-+---+----+----+-----+----+--++--+--++ +----+--+--+-------+-----+ | |
+ + + + + + + + + + + + + | |
| | | | | | | | | | | | | | |
| | | | | +---+ | | | | | | | |
| | | | | | | | | | | | | |
+ + + + + + + + + + + + | |
+-+---+----+----+-----+----+------+--+-----------------+--+--+-------+-----+ | |
| GND D7 D6 D5 D4 5V GND D8 D3 D2 5V GND | | |
|--------------------------------------------------------------------------| | |
| ARDUINO | | |
+--------------------------------------------------------------------------+ | |
*/ | |
#include <SoftwareSerial.h> | |
int bluetoothTx = 2; // TX-O | |
int bluetoothRx = 3; // RX-I | |
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); | |
enum ePinMapping { | |
Up = 4, | |
Down = 5, | |
Left = 6, | |
Right = 7, | |
Play = 8 | |
}; | |
int Period = 50; | |
int aPin = 0; | |
void setupBluetooth() | |
{ | |
bluetooth.begin(115200); // Default baud rate for bluetooth | |
bluetooth.print("$$$"); // CMD mode | |
delay(100); // Short delay, wait for the Mate to send back CMD | |
bluetooth.println("U,9600,N"); // Temporarily Change the baudrate to 9600, no parity | |
bluetooth.begin(9600); // Start bluetooth serial at 9600 | |
} | |
void setup() | |
{ | |
Serial.begin(9600); | |
setupBluetooth(); | |
pinMode(Up, OUTPUT); | |
pinMode(Down, OUTPUT); | |
pinMode(Left, OUTPUT); | |
pinMode(Right, OUTPUT); | |
pinMode(Play, OUTPUT); | |
} | |
int commandToPin(const char iData) | |
{ | |
switch(iData) | |
{ | |
case 'U': return Up; | |
case 'D': return Down; | |
case 'L': return Left; | |
case 'R': return Right; | |
case 'P': return Play; | |
default: return 0; | |
} | |
} | |
void activatePin(const int iPin) | |
{ | |
digitalWrite(iPin, HIGH); | |
delay(Period); | |
digitalWrite(iPin, LOW); | |
} | |
bool dataAvailable() | |
{ | |
//return (Serial.available() > 0); | |
return (bluetooth.available() > 0); | |
} | |
char dataRead() | |
{ | |
//return Serial.read(); | |
return bluetooth.read(); | |
} | |
void loop() | |
{ | |
// Receive data from serial port | |
if(dataAvailable()) | |
{ | |
aPin = commandToPin(dataRead()); | |
if(aPin) | |
activatePin(aPin); | |
} | |
} |
A video and photos in next days...
No comments:
Post a Comment