This project brings WALL-E to life. It was a simple plastic toy but now it's a Wii Nunchuk controlled robot that can move left, right, forward and backward and moves his arms forward and backward.
I removed two motors with their gears from old cd-rom/dvd player and made wheels from plastic bottle caps:
Insert the eyes:
WALL-E needs some plastic removed/cut-out to fit in the wheels, the gears and the motor:
Put together:
Connecting the Nunchuk and make cutting-markings for 2 motors for the arms:
Fitting in the motors for the arms:
Reconnecting the gears:
Adding PVC pipes to the last gears and connected the ropes to the arms:
Test-ride:
Now as a rookie i'm sure I made mistakes in the code or the wiring so please let me know if you have any suggestions/corrections. Don't hold back ;)
UPDATE 07/01/2021:Added motion control by using the acceleration-meter in the Nunchuk. So now, if the Z-button is pressed, you don't have to use the joystick anymore, just move your hand in any direction:
Here's the new code:
//L293D
//Motor A
const int motorPin1 = 9; // Pin 14 of L293
const int motorPin2 = 10; // Pin 10 of L293
//Motor B
const int motorPin3 = 6; // Pin 7 of L293
const int motorPin4 = 5; // Pin 2 of L293
//This will run only one time.
#include <Wire.h>
#include "Nunchuk.h"
void setup() {
Serial.begin(9600);
Wire.begin();
// Change TWI speed for nuchuk, which uses Fast-TWI (400kHz)
Wire.setClock(400000);
// nunchuk_init_power(); // A1 and A2 is power supply
nunchuk_init();
//Set pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void loop() { //open loop
if (nunchuk_read()) { //open if
// Work with nunchuk_data
byte nunZ = nunchuk_buttonZ();
if (nunZ != 0){ // if button Z is pressed we run accel mode
Serial.print("joy accelX: ");
Serial.println(nunchuk_accelX());
Serial.print("joy accelY: ");
Serial.println(nunchuk_accelY());
Serial.print("Z: ");
Serial.println(nunZ);
int nunAccel = nunchuk_accelX();
int nunAccelY = nunchuk_accelY();
if(nunAccel > 20){ //left
int nunZXpos = map(nunAccel, 0, 180, 0, 240);
analogWrite(motorPin1, nunZXpos);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, nunZXpos);
}
else if(nunAccelY < -20){ // backward
int nunZYpos = map(nunAccelY, 0, -216, 0, 240);
analogWrite(motorPin1, 0);
analogWrite(motorPin2, nunZYpos);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, nunZYpos);
}
else if(nunAccelY > 20){ // forward
int nunZYneg = map(nunAccelY, 0, 180, 0, 240);
analogWrite(motorPin1, nunZYneg);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, nunZYneg);
analogWrite(motorPin4, 0);
}
else if (nunAccel < -20){ // backward
int nunZXneg = map(nunZ, 0, -180, 0, 240);
analogWrite(motorPin1, 0);
analogWrite(motorPin2, nunZXneg);
analogWrite(motorPin3, nunZXneg);
analogWrite(motorPin4, 0);
}
else { //do nothing
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 0);
}
}else{
int nunX = nunchuk_joystickX();
int nunY = nunchuk_joystickY();
if (nunX < -20) { // IF X axe is a lower than 20 we go left
int nunXneg = map(nunX, 0, -100, 0, 240); //240 is the maximum speed for the motor
Serial.println(nunXneg);
analogWrite(motorPin1, 0);
analogWrite(motorPin2, nunXneg);
analogWrite(motorPin3, nunXneg);
analogWrite(motorPin4, 0);
}else if(nunX > 20) { // IF X is higher than 20 we go right
int nunXpos = map(nunX, 0, 100, 0, 240);
Serial.println(nunXpos);
analogWrite(motorPin1, nunXpos);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, nunXpos);
}else if(nunY < -20) { // IF Y is lower than 20 we go forward
int nunYneg = map(nunY, 0, -100, 0, 240);
Serial.println(nunYneg);
analogWrite(motorPin1, 0);
analogWrite(motorPin2, nunYneg);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, nunYneg);
}else if(nunY > 20) { // IF Y axe is higher than 20 we go backward
int nunYpos = map(nunY, 0, 100, 0, 240);
Serial.println(nunYpos);
analogWrite(motorPin1, nunYpos);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, nunYpos);
analogWrite(motorPin4, 0);
}else { //if joystick is not moved we do nothing
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 0);
}
delay(10);
}
} //end if
} //end loop
Comments