Bluetooth  Controlled LEGO Toy Car

Bluetooth Controlled LEGO Toy Car © CERN-OHL

Enjoy teaching your kids basic electronics and as a reward get them a unique Toy.

  • 2,997 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

Motivation

My motivation was my kids. I want to share time and have fun with them teaching them some basic concepts about projects and electronics.

As PM I assigned some tasks for one of them in this project: to build a Lego car to be used for installing the Arduino board, the wheels and motors coupled and space to install 9V batteries. This mission was given in a piece of paper and a specific date was established. My intention is to use this experience in the near future for a GO-KART prototype.

Conceptual idea

To copy the old idea of building a TOY CAR controlled by Bluetooth from a smartphone.

Main Concern

My main concern about this project is that doesn't exist batteries that really can be cheap and long time feeder for this kind of toys. So the scientific community has a challenge to solve the problem: How to obtain electric power supply cheap and easy for portable devices and toys and other future devices with motors?

Project development

In this case I went on agile techniques to develop projects:  few documents, quick schemes and drafts, not complicated engineering, just selecting parts, buying parts, connecting parts, interconnecting parts, plugging and playing with the toy.  In projects this orientation  is called FFP - Fit For Purpose.

The steps were:

1. Selecting and buying the parts:

2. Interconnecting  parts

3. Bill of materials issuing

4. Assembling parts in the LEGO toy car

5. Code development. See software details.

6. App Development- CarriTomas

7. Testing  the LEGO Toy Car in the prototype garage

With the APP available we tested all the commands and speed selection available for the LEGO Toy Car.

We even spent a lot of time tuning right-turn and left-turn instructions and concluded that it would better to use Direction with servo instead a Free Wheel. The behavior of the toy is random. Looking at this in a positive way, the random behavior of the Lego car is a source of fun for the kids. Using servo will have more power consumption but a smooth control.

In this video we can see the test in the "garage" of the LEGO Toy Car:

Testing 

8. Normal operation

Prototype Operation

Final Notes and Lessons Learned

  • Kids really enjoy this project, and it is impossible to prevent them from touching the parts, so be sure you have the best safety practices. Remember, always check your practices, design isolation, before start the toy with kids. App should be always operated by an adult.
  • We are far away from having commercial and cheap batteries that can be used with this kind of toys - this is a market opportunity.
  • My GO-Kart Project should be developed based on combustion motors, it is mandatory  if I want to enjoy the investment having a low price of operation power source, to move it.
  • SCRUM projects techniques used on this prototype were very important in this kind of developments.
  • Bluetooth controls could be disconnected if your car is moving quickly and  far from you or for random conditions, so it would be nice to install a local on/off switch, and be all the time as near as possible.
  • When the battery voltage level (used to feed the motor)  goes down it is possible to loose control of one motor control for forward and backward commands.
  • The L298N bridge has very good performance and power output, so the creativity for using this part is triggered doing this prototype.
  • Android studio platform is quickly adjustable for this APP requirement.

Code

CarritomasTAB.inoC/C++
//Update No.: 2 ( Beta Version)  original version issued: August_29_2016
//Developed by : Hernando Bolaos
//***********************************************************************************************************************************************
//Disclaim Note:
//THIS SOFTWARE IS PROVIDED BY THE DEVELOPER "AS IS" AND ANY EXPRESSED OR 
//IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
//OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
//IN NO EVENT SHALL THE DEVELOPER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
//INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
//STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
//IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
//THE POSSIBILITY OF SUCH DAMAGE.
//*************************************************************************************************************************************************




const int ENB = 3;
const int IN4 = 5;
const int IN3 = 6;
const int ENA = 11;
const int IN2 = 9;
const int IN1 = 10;



byte speed = 0;
char data=0;


void setup() {
  pinMode(ENB, OUTPUT); //Set  digital output PWM as  motor 1 speed value
  pinMode(IN4, OUTPUT); //Set digital otuput PWM as motor 1 direction A
  pinMode(IN3, OUTPUT); //Set digital ouput  PWM as motor 1 direction B 
  pinMode(ENA, OUTPUT); //Set digital output PWM as motor 2 speed value
  pinMode(IN2, OUTPUT); //Set digital output PWM as motor 2 direction B
  pinMode(IN1, OUTPUT); //Set digital output PWM as motor 2 direction A
  
  Serial.begin(9600);   //Sets the baud for serial data transmission 
}

 void loop() {

if(Serial.available() > 0)      // Send data only when you receive data:
          
           {
           data = Serial.read();        //Read the incoming data & store into data
           Serial.print(data);          //Print Value inside data in Serial monitor
           Serial.print("\n");   
           delay(200);    
 

             if(data == 'F')    {            // Checks whether value of data is equal to 1 - it works as pulse and latching
            
            Serial.println("  Forward command Received on Bluetooth - F !!!  ");   //Send message to serial 
            forward();
            delay(100);
            
               
         
         }

            
            if(data == 'B')   {      //  Checks whether value of data is equal to B - it works as pulse and latching
           
           Serial.println(" Backward Command received on Bluetooth - B !!!  ");   //Send message to serial 
           
           backward();
           delay(100);

           

           
             }

 

           if(data == 'S')    {            // Checks whether value of data is equal to S - it works as pulse and latching



            Serial.println(" Stop command received on  Bluetooth - S !!!  ");
            pare();
            delay(100);
       
         
         }

        if(data == 'L')    {            // Checks whether value of data is equal to L - it works as pulse and latching



            Serial.println(" Left command Received on Bluetooth - L !!!  ");
           leftF();
           delay(2000);
           forward();
       
         
      }

          if(data == 'R')    {            // Checks whether value of data is equal to R - funciona como pulso



            Serial.println(" Right command received on Bluetooth - R !!!  ");//Send message to serial 
            rightF();
           delay(2000);
           forward();
       
         
        }

       if(data == 'X')    {            // Checks whether value of data is equal to R - it works as pulse and latching



            Serial.println(" Left command received on Bluetooth - R !!!  ");//Send message to serial 
            leftB();
           delay(2000);
           backward();
       
         
        }

      if(data == 'Y')    {            // Checks whether value of data is equal to R - it works as pulse and latching



            Serial.println(" Right command received on Bluetooth - R !!!  ");//Send message to serial 
           rightB();
           delay(2000);
           backward();
       
         
        }




      if(data == 'V')    {            // Checks whether value of data is equal to R - funciona como pulso



            Serial.println(" Vmin received on Bluetooth - V !!!  ");//Send message to serial 
            speed = 80; // Sets Vmin output = 80
       
         
        }


     if(data == 'W')    {            // Checks whether value of data is equal to R - funciona como pulso



            Serial.println(" Vmed received on Bluetooth -W !!!  ");//Send message to serial 
            speed = 128;// Sets Vmed output = 128
       
         
        }



     if(data == 'Z')    {            // Checks whether value of data is equal to R - funciona como pulso



            Serial.println(" Vmax received on Bluetooth - Z !!!  ");//Send message to serial 
            speed = 255;// Sets Vmax output = 255
       
         
        }
       
           }


 
 
}

void backward() { //Backward routine

  digitalWrite (IN1, HIGH);
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, HIGH);
  digitalWrite (IN4, LOW);

analogWrite(ENA, speed);
analogWrite(ENB, speed);


}

void forward() {  //Forward routine
  digitalWrite (IN1, LOW);  
  digitalWrite (IN2, HIGH);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, HIGH);

analogWrite(ENA, speed);
analogWrite(ENB, speed);

}


void pare() {        //Stop
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);

}


void leftF() {             //Left going Forward routine
digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, HIGH);

analogWrite(ENA, speed);
analogWrite(ENB, 0);
}


void rightF() {         //Right going forward routine 
digitalWrite (IN1, LOW);
  digitalWrite (IN2, HIGH);
  digitalWrite (IN3, LOW);
  digitalWrite (IN4, HIGH);

analogWrite(ENA, 0);
analogWrite(ENB, speed);
}


void leftB() {             //Left going backward routine
digitalWrite (IN1, HIGH);
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, HIGH);
  digitalWrite (IN4, LOW);

analogWrite(ENA, speed);
analogWrite(ENB, 0);
}


void rightB() {         //Right going backward routine
  digitalWrite (IN1, HIGH);
  digitalWrite (IN2, LOW);
  digitalWrite (IN3, HIGH);
  digitalWrite (IN4, LOW);

analogWrite(ENA, 0);
analogWrite(ENB, speed);
}

Schematics

carritomasTABSchem_bb.jpg
Carritomastabschem bb
carritomasTABSchem_schem.png
Carritomastabschem schem

Comments

Author

Hernanduino
Hernanduino
  • 3 projects
  • 19 followers

Additional contributors

  • Sample code for one motor local control by Andres cruz - electronilab .co
  • App development and sample code bluetoothchat by Android Studio platform creators

Published on

September 6, 2016

Members who respect this project

DefaultDefaultNutshelPhotoErospeterDefault

and 3 others

See similar projects
you might like

Similar projects you might like

Bluetooth Controlled Car

Project in progress by samanfern

  • 4,194 views
  • 16 comments
  • 31 respects

RC Car to BT Car Controlled with Blynk

Project tutorial by Team Daxes Hacks

  • 3,600 views
  • 2 comments
  • 6 respects

Robotic Car Controlled over Bluetooth by Andriod Phone

Project showcase by S.Ranjith Reddy

  • 4,429 views
  • 0 comments
  • 9 respects

Turn your RC Car to Bluetooth RC car

Project tutorial by Prajjwal Nag

  • 11,968 views
  • 1 comment
  • 11 respects

Bluetooth Controlled Car

Project showcase by Ian St. Louis

  • 10,740 views
  • 3 comments
  • 12 respects

PlayStation Remote Controlled Wireless Car

Project showcase by Jasmeet Singh

  • 2,586 views
  • 1 comment
  • 6 respects
Add projectSign up / Login