Introduction: Build a Big Crane Game
How to build a whole room crane game. Based on the arcade style 'Crane Game' or 'Claw Machine'. This is a continuation of a previus instructable titled CRANE GAME in which we built a 2-axis crane game in a door frame. We have now added a third axis and wireless control. And made it big.
**
October 2013
real arcade machine claw
https://www.tindie.com/products/marc_cryan/claw/
***
*** September 2013 **
I have a project running on tindie.com for a real claw machine kit.
****
A few technical and functional improvements:
7MbrDo5RalI
Overview
**
October 2013
real arcade machine claw
https://www.tindie.com/products/marc_cryan/claw/
***
I have a project running on tindie.com for a real claw machine kit.
****
A few technical and functional improvements:
- Less wires - controllers and batteries move with the motors and are signaled with IR light.
- Precision not needed - I was able to set-up a 8x10ft track without measuring anything
- Reproducible - used standard parts, used the same components in many spots
- Expandable - use longer tracks to make it bigger - track cost is about 50cents a foot.
- Removable - hangs from the ceiling by 4 small hooks
- Future? Could be used as basis for a big 3D printer
7MbrDo5RalI
Overview
- Materials
- Frame
- X-Axis Mechanical
- Y-Axis Mechanical
- Z-Axis Mechanical
- X-Axis Electronics
- Y-Axis Electronics
- Z-Axis Electronics
- IR Control Overview
- IR Receive Circuit
- IR Transmitter (TV remote)
- IR Decode Process
- X-Axis Control Code
- Y/Z - Axis Control Code
- What's next?
- Complete Wiring
- Complete Code
Step 1: Materials
Materials:
6 - 8' J channel
7 - Big continous servo motors -- HobbyPartz --- EXI-Servo-B1226
1 - Roll of electrical tape
2 - Arduino UNO boards
3 - Small peices of perferatored board
2 - IR de-modulator
1 - Universal TV remote control
1 - 25' coiled phone chord
1 - 15' straight phone chord
1 - Roll packing tape
1 - Pre-made claw with servo -- Spark Fun ROB-10332
2 - 4 AA battery packs, rechargeable -- eneloop AA,
6 - screw hooks
3 - Peice plywood - 2x6" each
1 - roll metal plumbers strap
Tools:
- Drill
- Computer
- Soldering iron
6 - 8' J channel
7 - Big continous servo motors -- HobbyPartz --- EXI-Servo-B1226
1 - Roll of electrical tape
2 - Arduino UNO boards
3 - Small peices of perferatored board
2 - IR de-modulator
1 - Universal TV remote control
1 - 25' coiled phone chord
1 - 15' straight phone chord
1 - Roll packing tape
1 - Pre-made claw with servo -- Spark Fun ROB-10332
2 - 4 AA battery packs, rechargeable -- eneloop AA,
6 - screw hooks
3 - Peice plywood - 2x6" each
1 - roll metal plumbers strap
Tools:
- Drill
- Computer
- Soldering iron
Step 2: Frame
Frame:
X-Axis -
To Make the Tracks:
Using 6 peices of J channel, make 3 tracks
Hang X-axis
Prepare Y-axis
X-Axis -
-The X-Axis consists of 2 parrallel tracks mounted to the ceiling about 9' appart
Y-Axis -One track that is supported on either end by the Y-Axis
To Make the Tracks:
- Place 2 J channels back-to-back
- Run a peice of clear tape down the top seam, and fold over
- Run a second peice of tape along the bottom
Using 6 peices of J channel, make 3 tracks
Hang X-axis
-Put 2 screw hooks in the ceiling, one at each end of the expected X tracks
-Cut 4 peices of plumbers strap, about 6 inches long
-Thread the peice of plumbers strap towards the end of each track
-Bend the plumbers strap, like an L, so that it will hold up the track
-Hang the other end of the plumbers strap on the hooks on the ceiling
-Adjust as needed
-Cut 4 peices of plumbers strap, about 6 inches long
-Thread the peice of plumbers strap towards the end of each track
-Bend the plumbers strap, like an L, so that it will hold up the track
-Hang the other end of the plumbers strap on the hooks on the ceiling
-Adjust as needed
Prepare Y-axis
-The Y axis will be suspended from the motorized carriages on the X-axis
-For now, cut 2 more pieces of plumbers strap and thread through each end of Y-axis
-For now, cut 2 more pieces of plumbers strap and thread through each end of Y-axis
Step 3: X - Axis Mechanical
X-Axis Mechanica
The X axis has 2 motorized carrages
Modify servos for continous rotation
-Take the 4 screws out of the fron of the motor
-Take off the smaller part of the plastic shell
-Disassemble gears
-There is a small white disk around the shaft of the potentioometer
-Remove the smal white disk
-Re-assemble
Make plywood base
- Cut 2 pecised of 1/4 ply (used MDF) to 3x6"
- Drill/cut 2 slots in each peice - 1/4" wide, 2inch long, and 3.5" apart [CHECK THIS]
Attach Servos
-Attach a large wheel to the servo, use a screw
-Wrap wheel with something for friction (used this sticky foam)
-Put the servo Bracket in the slot
-Wrap servo and base with electrical tape to secure
-Repeat with the second servo
-When done, weels should be a little less than 1/8" appart (3/32" ?)
Hang the assembled carraiges, one on each X axis
Put an eye-hook on the bottom of each platform
Hange the Y-axis track from these hooks using plumbers strap
The X axis has 2 motorized carrages
Modify servos for continous rotation
-Take the 4 screws out of the fron of the motor
-Take off the smaller part of the plastic shell
-Disassemble gears
-There is a small white disk around the shaft of the potentioometer
-Remove the smal white disk
-Re-assemble
Make plywood base
- Cut 2 pecised of 1/4 ply (used MDF) to 3x6"
- Drill/cut 2 slots in each peice - 1/4" wide, 2inch long, and 3.5" apart [CHECK THIS]
Attach Servos
-Attach a large wheel to the servo, use a screw
-Wrap wheel with something for friction (used this sticky foam)
-Put the servo Bracket in the slot
-Wrap servo and base with electrical tape to secure
-Repeat with the second servo
-When done, weels should be a little less than 1/8" appart (3/32" ?)
Hang the assembled carraiges, one on each X axis
Put an eye-hook on the bottom of each platform
Hange the Y-axis track from these hooks using plumbers strap
Step 4: Y-Axis Mechanical
The Y axis has one carraige.
Make the carraige just like the ones for the X axis.
But -- add a third servo, tapped to the bottom of the platform. This will control the claw (Z axis)
Make the carraige just like the ones for the X axis.
But -- add a third servo, tapped to the bottom of the platform. This will control the claw (Z axis)
Step 5: Z-axis Mechanical
Tie a 8-10 ft string to the wheel on the third servo of the Y axis carriage
Assemble a claw -- used claw from sparkfun __________
Tie claw to other end of string
Assemble a claw -- used claw from sparkfun __________
Tie claw to other end of string
Step 6: X-axis Electronics
Slave X-axis board
- Cut a piece of proto board about 1x1"
- Follow the schematic to solder on 2 3-pin headers and 3 screw terminals (used 4, 2 sets of 2)
- Cut a 12' lenth of non-curly phone chord.
- Tape cord to the bottom of the Y-axis
- Connect 3 wires to the proto board
- Using electrical tape, attach proto board to X-axis carraiage
***
Arduino pins used:
D11 IR receive
D9 Servo Xa
D10 Servo Xb
Step 7: Y Axis Electronics
Master X-axis board - this attaches to an arduino, like a mini-sheild.
This board had connectors for 3 servo motors (2 for Y axis, 1 for Z). It will also have screw terminals for power. In addition to the connectors it will have an IR reciever, this is a special component that decodes IR signals from TV remotes and then sends them out to the arduino.
Here are the parts:
***
Aduino pins used:
D11 - IR receiver
D9 Servo Ya
D10 Servo Yb
D2 Servo Z
D6 Servo Claw
This board had connectors for 3 servo motors (2 for Y axis, 1 for Z). It will also have screw terminals for power. In addition to the connectors it will have an IR reciever, this is a special component that decodes IR signals from TV remotes and then sends them out to the arduino.
Here are the parts:
- Cut a peice of proto boardboard about 1x3"
- Cut 3 peices of header that are 3 pins long (these will go to servos)
- Cut 4 pecies of header that have just one pin (these will go to control pins on arduino and to ground)
- A 2 terminal screw terminal (for power)
- Arduino ground connects to battery negative
- Servos have 3 pins; power, ground, and control. All the grounds can be connected together, and to Arduino ground.
- All the power pins can be connected to the battery positive terminal. Each control pin goes to a seperate pin on the Arduino board.
- The IR decoder connector has 3 pins; power, ground and a data out. Power goes to the 5V port on the arduino. Ground goes to Arduino ground. And Data out goes to its own pin on the Arduino.
- When assembled the servo connectors and the screw terminals are on the top of the board. The single pin connections come out the bottom of the board and go to the Arduino pins.
***
Aduino pins used:
D11 - IR receiver
D9 Servo Ya
D10 Servo Yb
D2 Servo Z
D6 Servo Claw
Step 8: Y and Z Axis Electronics
The Zaxis doesn't have it's own board. It is just goes to one of the connectors on the Y board. 1 servo opens and clses the claw, one servo raises and loweres the claw by winding up a string on a spool.
Step 9: IR Control Overview
IR signals are send from a universal television remote control. The signals are received by the Arduinos on the X and Y axis.
General steps:
General steps:
- build a circuit to get the signals
- decode some signals for from the controller
- program the Arduinos do do things when they get a signal.
Step 10: IR Receiver Circuit
The circuit to recieve IR signals is pretty simple, as long as you have right parts! Mainly an IR receiver and demodulator.
The IR reciever has 3 pins; power (to 5V on arduino), ground (to arduino ground), and a digital output pin (sends data to a pin on the arduino).
Here is the IR receiver I am using: IR Sensor IC 38KHZ Vishay Infrared Receivers - Mfg p/n TSOP38238SS1V - mouser p/n 782-TSOP38238SS1V -- Pinouts are 1:data out, 2:Grnd: 3:Vs (supply Voltage, 5V). Facing the bump pine 1 is on the left.
The IR reciever has 3 pins; power (to 5V on arduino), ground (to arduino ground), and a digital output pin (sends data to a pin on the arduino).
Here is the IR receiver I am using: IR Sensor IC 38KHZ Vishay Infrared Receivers - Mfg p/n TSOP38238SS1V - mouser p/n 782-TSOP38238SS1V -- Pinouts are 1:data out, 2:Grnd: 3:Vs (supply Voltage, 5V). Facing the bump pine 1 is on the left.
Step 11: IR Decode Process
The buttons we are using are: up, down, left, right, select, and menu. DVD players usually use all these buttons, so program the TV remote to send DVD signals from a DVD player that you do not have.
For the univerasal remove, have used code: 1119 which is for a ACESONIC DVD player.
(to program remote; hold setup; press dvd; 1119)
The code below will display the values that the arduino gets from the remote.
Write down the numbers for each button. These numbers will be added to the Arduino code.
Arduino Code:
/// read IR remote
//IR setup - stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
long x = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons
if (irrecv.decode(&results)) {
x = results.value;
Serial.println(results.value, HEX); //for decoding buttons
Serial.println(x);
delay(100);
irrecv.resume();
}
}
For the univerasal remove, have used code: 1119 which is for a ACESONIC DVD player.
(to program remote; hold setup; press dvd; 1119)
The code below will display the values that the arduino gets from the remote.
Write down the numbers for each button. These numbers will be added to the Arduino code.
Arduino Code:
/// read IR remote
//IR setup - stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
long x = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons
if (irrecv.decode(&results)) {
x = results.value;
Serial.println(results.value, HEX); //for decoding buttons
Serial.println(x);
delay(100);
irrecv.resume();
}
}
Step 12: X-axis Control Code
The X axis moves in two directions.
X-axis code:
#include <Servo.h>
#include <Wire.h>
Servo XA;
Servo XB;
int dir = 0;
int oldDir = 0;
//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
//
unsigned long time;
unsigned long timeIR;
unsigned long timeDiff;
void setup(){
Wire.begin();
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
// Serial.println(x);
timeIR = millis(); //record time of button push
switch(x){
case 351005205:
action = "up arrow";
dir = 5;
break;
case 350988375:
action = "down arrow";
dir = 6;
break;
case 350963895:
action = "left arrow";
dir = 1;
break;
case 350976645:
action = "right arrow";
dir = 2;
break;
case 350952165:
action = "ok/mute";
dir = 3;
break;
case 350986335:
action = "B2";
dir = 4;
break;
case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}
timeDiff = millis() - timeIR;
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}
if(action != oldAction){
if (action == "up arrow"){
XA.attach(9);
XA.write(0);
XB.attach(10);
XB.write(180);
Serial.println("X go away");
delay(100);
}
if(action == "down arrow"){
XA.attach(9);
XA.write(180);
XB.attach(10);
XB.write(0);
Serial.println("X come back");
delay(100);
}
if ((action == "none") && (oldDir == 5 || oldDir==6)){
XA.detach();
XB.detach();
Serial.println("stop x axis");
}
//send commands
Wire.beginTransmission(9);
Wire.send(dir);
Wire.endTransmission();
Serial.println("send dir ");
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);
}
X-axis code:
#include <Servo.h>
#include <Wire.h>
Servo XA;
Servo XB;
int dir = 0;
int oldDir = 0;
//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
//
unsigned long time;
unsigned long timeIR;
unsigned long timeDiff;
void setup(){
Wire.begin();
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
// Serial.println(x);
timeIR = millis(); //record time of button push
switch(x){
case 351005205:
action = "up arrow";
dir = 5;
break;
case 350988375:
action = "down arrow";
dir = 6;
break;
case 350963895:
action = "left arrow";
dir = 1;
break;
case 350976645:
action = "right arrow";
dir = 2;
break;
case 350952165:
action = "ok/mute";
dir = 3;
break;
case 350986335:
action = "B2";
dir = 4;
break;
case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}
timeDiff = millis() - timeIR;
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}
if(action != oldAction){
if (action == "up arrow"){
XA.attach(9);
XA.write(0);
XB.attach(10);
XB.write(180);
Serial.println("X go away");
delay(100);
}
if(action == "down arrow"){
XA.attach(9);
XA.write(180);
XB.attach(10);
XB.write(0);
Serial.println("X come back");
delay(100);
}
if ((action == "none") && (oldDir == 5 || oldDir==6)){
XA.detach();
XB.detach();
Serial.println("stop x axis");
}
//send commands
Wire.beginTransmission(9);
Wire.send(dir);
Wire.endTransmission();
Serial.println("send dir ");
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);
}
Step 13: Y and Z Axis Code
The code to control the Y and Z axii are both loaded onto the same Arduino., So the code is all in one program.
The Y axis moves in 2 directions, the Z axis goes up and down, and the claw is opened and closed.
Arduino Code:
#include <Servo.h>
#include <Wire.h>
Servo YA;
Servo YB;
Servo Z;
Servo Claw;
//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
unsigned long time;
unsigned long timeIR;
unsigned long timeDiff;
int dir = 0;
int oldDir = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
//Serial.println(x);
timeIR = millis(); //record time of button push
switch(x){
case 351005205:
action = "up arrow";
dir = 5;
break;
case 350988375:
action = "down arrow";
dir = 6;
break;
case 350963895:
action = "left arrow";
dir = 1;
break;
case 350976645:
action = "right arrow";
dir = 2;
break;
case 350952165:
action = "ok/mute";
dir = 3;
break;
case 350986335:
action = "B2";
dir = 4;
break;
case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}
timeDiff = millis() - timeIR;
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}
if(action != oldAction){
if (action == "left arrow"){
YA.attach(9);
YA.write(0);
YB.attach(10);
YB.write(180);
Serial.println("Y go left");
delay(100);
}
if(action == "right arrow"){
YA.attach(9);
YA.write(180);
YB.attach(10);
YB.write(0);
Serial.println("Y go right");
delay(100);
}
if(action == "B2"){
Z.attach(2);
Z.write(180); //down
Claw.attach(6);
Claw.write(100); // open?
Serial.println("claw down and open");
delay(100);
}
if(action == "ok/mute"){
Z.attach(2);
Z.write(0); //up
Claw.attach(6);
Claw.write(20); // close?
Serial.println("claw up and close");
delay(100);
}
if((action == "none") && (oldDir == 1 || oldDir == 2 || oldDir == 3 || oldDir ==4)){
YA.detach();
YB.detach();
Z.detach();
Claw.detach();
Serial.println("all stop");
delay(100);
}
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);
}#include <Servo.h>
#include <Wire.h>
Servo YA;
Servo YB;
Servo Z;
Servo Claw;
//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
unsigned long time;
unsigned long timeIR;
unsigned long timeDiff;
int dir = 0;
int oldDir = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
//Serial.println(x);
timeIR = millis(); //record time of button push
switch(x){
case 351005205:
action = "up arrow";
dir = 5;
break;
case 350988375:
action = "down arrow";
dir = 6;
break;
case 350963895:
action = "left arrow";
dir = 1;
break;
case 350976645:
action = "right arrow";
dir = 2;
break;
case 350952165:
action = "ok/mute";
dir = 3;
break;
case 350986335:
action = "B2";
dir = 4;
break;
case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}
timeDiff = millis() - timeIR;
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}
if(action != oldAction){
if (action == "left arrow"){
YA.attach(9);
YA.write(0);
YB.attach(10);
YB.write(180);
Serial.println("Y go left");
delay(100);
}
if(action == "right arrow"){
YA.attach(9);
YA.write(180);
YB.attach(10);
YB.write(0);
Serial.println("Y go right");
delay(100);
}
if(action == "B2"){
Z.attach(2);
Z.write(180); //down
Claw.attach(6);
Claw.write(100); // open?
Serial.println("claw down and open");
delay(100);
}
if(action == "ok/mute"){
Z.attach(2);
Z.write(0); //up
Claw.attach(6);
Claw.write(20); // close?
Serial.println("claw up and close");
delay(100);
}
if((action == "none") && (oldDir == 1 || oldDir == 2 || oldDir == 3 || oldDir ==4)){
YA.detach();
YB.detach();
Z.detach();
Claw.detach();
Serial.println("all stop");
delay(100);
}
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);
}
The Y axis moves in 2 directions, the Z axis goes up and down, and the claw is opened and closed.
Arduino Code:
#include <Servo.h>
#include <Wire.h>
Servo YA;
Servo YB;
Servo Z;
Servo Claw;
//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
unsigned long time;
unsigned long timeIR;
unsigned long timeDiff;
int dir = 0;
int oldDir = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
//Serial.println(x);
timeIR = millis(); //record time of button push
switch(x){
case 351005205:
action = "up arrow";
dir = 5;
break;
case 350988375:
action = "down arrow";
dir = 6;
break;
case 350963895:
action = "left arrow";
dir = 1;
break;
case 350976645:
action = "right arrow";
dir = 2;
break;
case 350952165:
action = "ok/mute";
dir = 3;
break;
case 350986335:
action = "B2";
dir = 4;
break;
case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}
timeDiff = millis() - timeIR;
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}
if(action != oldAction){
if (action == "left arrow"){
YA.attach(9);
YA.write(0);
YB.attach(10);
YB.write(180);
Serial.println("Y go left");
delay(100);
}
if(action == "right arrow"){
YA.attach(9);
YA.write(180);
YB.attach(10);
YB.write(0);
Serial.println("Y go right");
delay(100);
}
if(action == "B2"){
Z.attach(2);
Z.write(180); //down
Claw.attach(6);
Claw.write(100); // open?
Serial.println("claw down and open");
delay(100);
}
if(action == "ok/mute"){
Z.attach(2);
Z.write(0); //up
Claw.attach(6);
Claw.write(20); // close?
Serial.println("claw up and close");
delay(100);
}
if((action == "none") && (oldDir == 1 || oldDir == 2 || oldDir == 3 || oldDir ==4)){
YA.detach();
YB.detach();
Z.detach();
Claw.detach();
Serial.println("all stop");
delay(100);
}
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);
}#include <Servo.h>
#include <Wire.h>
Servo YA;
Servo YB;
Servo Z;
Servo Claw;
//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
unsigned long time;
unsigned long timeIR;
unsigned long timeDiff;
int dir = 0;
int oldDir = 0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}
void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
//Serial.println(x);
timeIR = millis(); //record time of button push
switch(x){
case 351005205:
action = "up arrow";
dir = 5;
break;
case 350988375:
action = "down arrow";
dir = 6;
break;
case 350963895:
action = "left arrow";
dir = 1;
break;
case 350976645:
action = "right arrow";
dir = 2;
break;
case 350952165:
action = "ok/mute";
dir = 3;
break;
case 350986335:
action = "B2";
dir = 4;
break;
case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}
timeDiff = millis() - timeIR;
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}
if(action != oldAction){
if (action == "left arrow"){
YA.attach(9);
YA.write(0);
YB.attach(10);
YB.write(180);
Serial.println("Y go left");
delay(100);
}
if(action == "right arrow"){
YA.attach(9);
YA.write(180);
YB.attach(10);
YB.write(0);
Serial.println("Y go right");
delay(100);
}
if(action == "B2"){
Z.attach(2);
Z.write(180); //down
Claw.attach(6);
Claw.write(100); // open?
Serial.println("claw down and open");
delay(100);
}
if(action == "ok/mute"){
Z.attach(2);
Z.write(0); //up
Claw.attach(6);
Claw.write(20); // close?
Serial.println("claw up and close");
delay(100);
}
if((action == "none") && (oldDir == 1 || oldDir == 2 || oldDir == 3 || oldDir ==4)){
YA.detach();
YB.detach();
Z.detach();
Claw.detach();
Serial.println("all stop");
delay(100);
}
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);
}
Step 14: Assembly
X axis motors/boards things (carriages?) hang from the X-axis tracks that hang from the ceiling.
The Y axis tracks hang from the X-axis carriages.
The Y axis carriage goes on the Y axis track.
The Y axis tracks hang from the X-axis carriages.
The Y axis carriage goes on the Y axis track.
Step 15: Play With It
Give the conroller to the kids and let them go nuts. The whole thing does move a bit slowly, but that is probably for the best.
Step 16: VIDEO
Here are some more videos....
This sort of shows that a claw on a string is not a very good way to pick things up!
Fail to pick up Kermit
Fail to pick up Shoe
Fail to pick up Shoe again
Fail to pick up Sock
Cheat to pick up sock, track gets stuck
Pick up several items -- some success --- plastic bag, shoe
This sort of shows that a claw on a string is not a very good way to pick things up!
Fail to pick up Kermit
Fail to pick up Shoe
Fail to pick up Shoe again
Fail to pick up Sock
Cheat to pick up sock, track gets stuck
Pick up several items -- some success --- plastic bag, shoe
Step 17: What's Next
A few basic things to improve:
- Claw is not great, probably just need more power to the open/close servo
- Batteries have to be removed and to recharge them, so that is a hassle
- If you move to a different spot in the room the controls no longer make sense
- Control with SmartPhone
- Add some automation; can some routines be preprgrammed?
- Add sensors/camera so the claw can find stuff on its own?
- Maybe write a program to have the claw take stuff out of a toy box and arrange it in the room? Could it be used to serve salad?
Step 18: Complete Wiring
Here is all the wiring in one place.
PDF and Eagle Schematic
Probably has errors.
*correction* - Zservo should go to D5
PDF and Eagle Schematic
Probably has errors.
*correction* - Zservo should go to D5
Attachments
Step 19: Complete Code
Here is all the code in one place: