Blockvader - May the Force Be With You
by Khang Nguyen in Circuits > Robots
5955 Views, 25 Favorites, 0 Comments
Blockvader - May the Force Be With You
Over the years, I have seen many interesting 3D printed rover robot projects and I love how 3D printing technology has helped the robotic community to grown more diversity in design and material choices. I want to add a small contribution to the robotic community by publishing MrK_Blockvader on Instructable for the Maker Community.
MrK_Blockvader is a fun little robot with tiny buzzer, but don't let the blocky look fools you. He could be equipped with the color sensor, distance sensor, a radio module to communicate with other Blocky with alike capability, with a base or with a controller.
MrK_Blockvader will be part of a robot network where one can be assigned as the commander to a group of robots to archive the same objective.
Supplies
1 * Arduino Nano
1 * DC motor driver
1 * 650 mAh Venom LiPo battery
2 * White LEDs
1 * Distance sensor
1 * Color sensor
1 * Buzzer
1 * Switch
3D Printing
I use the CEL Robox 3D printer printed with carbon material for lightweight and durability. I will attach the STL files below. Please put on the comment if you have any questions regarding the 3D printing process and setting.
Prepare the Arduino Nano
I have learned that perform prep work to all the electric components is key to a clean project.
This project includes wiring up the nRF24 breakout board, I have done this in a separate project calls NRF24 Wireless LED Box, this is where you can find the information on how to wire up the nRF24 breakout board to an Arduino.
Note: I use thicker 22AWG wire for powering the Nano and thin 26 AWG blue and black wires for all other signal purposes. I love these 26 AWG size wires, they are flexible but yet strong provide the best of both worlds.
- Arduino Nano prep work:
- Solder the signal pin header to the Arduino Nano.
- Wet these pins with the solder will make the soldering much easier later.
- Solder a group of blue wire to the 5V to supply power to all the sensors and LEDs.
- Solder a group of black wire to the GND to provide ground to all the sensors and LEDs.
- NRF 24 breakout board prep work:
- Solder 5 wires to the nRF24 breakout board for the signals.
- Solder 2 wires to the nRF24 breakout board for the power.
- Check the link to make sure how to wire the breakout board to an Arduino.
- Solder the signal 5 wires from the nRF24 to the Arduino Nana.
- Buzzer prep work:
- Solder a black wire to one of the buzzer legs for ground.
- solder a blue wire to the other buzzer leg for signal control.
- Photoresistor prep work:(diagram available)
- Solder a blue wire to one of the photoresistor leg for 5V.
- Solder a 10K resistor to the other leg of the photoresistor.
- Solder a blue wire between the 10K resistor and the photoresistor for the signal.
- Solder a black wire to the 10K resistor for ground.
- LEDs prep work:
- Solder a blue wire from the positive right LED to the positive left LED.
- Solder a black wire from the negative right LED to the negative left LED.
- Solder a blue wire to the positive right LED for signal control.
- Solder a black wire to the negative right LED for ground.
Prepare DC Motor, DC Motor Driver and Sensors.
The MrK_Blockvador has a couple of sensor options and the additional sensors do not affect the overall operational, however, the color sensor will not be able to install after the DC motor is glued in place.
- DC motor prep work:
- Solder a black and a red wire to the DC motor.
- Wrap the end of the motor with lear tape.
- Fill the area with hot glue to seal the motor connectors.
- DC motor driver prep work:
- Solder the 6 signal wires on the Motor Driver.
- Solder the signal wire to the correct pin on the Arduino Nano.
- Install the 12V wires to power the motor driver from the battery. Make sure you have the wires long enough to run it down under and out the back of the robot.
- Install the 5V wires to power the Arduino Nano from the motor driver.
- Color Sensor prep work (optional):
- Solder the 2 wires for the signal.
- Solder the 2 wire for power.
- Solder the 1 wire to control the super bright LED.
- Distance sensor prep work: (optional)
- Solder a blue wire for the signal.
- Solder another blue wire on the positive port for positive 3V.
- Solder a black wire for on the negative port for ground.
Assemble
After all the prep work, now is the moment when things come together.
Note: I use hot glue for the DC motor and DC motor driver because hot glue can provide minor shock absorption and if you need to remove it, a little bit of rubbing alcohol will get the hot glue right off.
Assembling process:
- Hot glue the color sensor to the chassis and run the color sensor wire through the channel. (optional)
- Hot glue the DC motors to the chassis, make sure the DC motor sits flush with the chassis.
- Super glue Blocvader head to its chassis make sure all wires run through.
- Hot glue distance sensor. (optional)
- Hot glue LEDs for Blockvador eyes.
- Insert the DC motor wires to the DC motor driver all the way and screw-down firmly.
- Run the 12V power wires from the DC driver down under and out the back of the chassis for the on/off switch.
- Make sure all wires from all sensors are clear before glue down the DC motor driver.
- Upload test code and troubleshoot if there is any.
Code
Basic Code:
The robot using its photoresistor and detecting the light level of the room and react if there a change of light level over time
The heart of the code:
void loop()
{
lightLevel = analogRead(Photo_Pin);
Serial.print("Light level: ");Serial.println(lightLevel);
Serial.print("Current light: ");Serial.println(Current_Light);
if (lightLevel >= 200){ Chill_mode();analogWrite(eyes_LED, 50);Serial.println("Chill mode");}
if (lightLevel < 180){ Active_mode();analogWrite(eyes_LED, 150);Serial.println("Active mode");}
}
The robot can be controlled using a controller and switching to partial autonomous mode using the controller.
The heart of the code:
void loop()
{
int debug = 0;
lightLevel = analogRead(Photo_Pin);
Dis = analogRead(Dis_Pin);
// Check whether there is data to be received
if (radio.available())
{
radio.read(&data, sizeof(Data_Package));
if ( data.C_mode == 0){Trim_Value = 10; Direct_drive();}
if ( data.C_mode == 1){Trim_Value = 0; Autonomous_mode();}
if ( data.C_mode == 2){Trim_Value = 0; Chill_mode();}
if(debug >= 1)
{
if (data.R_SJoy_State == 0){Serial.print("R_SJoy_State = HIGH; ");}
if (data.R_SJoy_State == 1){Serial.print("R_SJoy_State = LOW; ");}
if (data.S_Switch_State == 0){Serial.print("S_Switch_State = HIGH; ");}
if (data.S_Switch_State == 1){Serial.print("S_Switch_State = LOW; ");}
if (data.M_Switch_State == 0){Serial.println("M_Switch_State = HIGH");}
if (data.M_Switch_State == 1){Serial.println("M_Switch_State = LOW");}
Serial.print("\n");
Serial.print("Rover Mode: ");Serial.println(data.C_mode);
Serial.print("L_XJoy_Value= ");Serial.print(data.L_XJoy_Value);
Serial.print("; L_YJoy_Value= ");Serial.print(data.L_YJoy_Value);
Serial.print("; R_YJoy_Value= ");Serial.print(data.R_YJoy_Value);
Serial.print("; Throtle_Value= ");Serial.println(data.Throtle_Value);
delay(debug*10);
}
lastReceiveTime = millis(); // At this moment we have received the data
}
// Check whether we keep receving data, or we have a connection between the two modules
currentTime = millis();
if ( currentTime - lastReceiveTime > 1000 ) // If current time is more then 1 second since we have recived the last data,
{ //that means we have lost connection
resetData(); // If connection is lost, reset the data. It prevents unwanted behavior, for example if a drone has a throttle up and we lose connection, it can keep flying unless we reset the values
}
}
What Next?
This project is the beginning of a larger project, where a network of these little guys works together to archive a common goal.
However, these robots would need to report their status to a communication station then this station would then combine all the reports from all the bots to then make a decision on what would be the next necessary action.
For that reason, the next phase of the project would be a controller to act as a communication station. This will help with developed the project further.
The controller itself is a robot, however, it is more passive than the Blockader. Therefore the controller desert its own instructable article, so tune in for a future project ;D