Introduction: Bluetooth LE Controlled Rocket Toy

About: "I'm so full of ideas and here's a good one..." Here I go again creating another prototype and proof of concept for one of my ideas from the Black Magic AI idea factory.

Have you ever dreamed of building your own rocket and exploring outer space? Now you can, kinda. Imagine you are chief engineer on the StarDust Mark I rocket ship and it is your job to install the ships computer and engine.
In this tutorial you will install a Bluetooth LE Arduino to control a LED and laser module to add interactivity to a model toy rocket. The laser will be the engine light and the LED will illuminate the cockpit. Although it is not covered in this tutorial, you can also expand the features of your toy rocket by adding servos, sensors and sound modules. Use your imagination to customize it for any space mission.

Supplies

1x Bluno Beetle BLE Low Power Controller (Robotshot.com Product Code : RB-Dfr-621)

1x Various LED 3mm Kit (35pk) (Robotshot.com Product Code : RB-Gra-26)

1x Laser Diode - 5mW 650nm Red (Adafruit PRODUCT ID: 1054)

1x 2 x 2032 Coin Cell Battery Holder - 6V output with On/Off switch (Adafruit PRODUCT ID: 783)

1x Plastic Model Rocket Toy (ICSO.space)

1x Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM w/ Bluetooth LE (google it!)

2x CR2032 Lithium Coin Cell Battery (Adafruit PRODUCT ID: 654)

Soldering Iron

Solder

Electrical Tape

Phillips screw driver

Step 1: Upload Controller Code to Arduino

/*
* icso Rocket Toy Bluetooth protocol control code. * Author: Maurice Tedder * Compile with Arduino/Genuino Uno. * * Changelog * 04/25/2020 - Adopted robot controller code for Bluno. */ #include <Servo.h>
// We need to use the 'raw' pin reading methods because timing is very important here
// and the digitalRead() procedure is slower!
#define AnalogInput_0 A0 //Sensors on Analog pin 0
#define AnalogInput_1 A1 //Sensors on Analog pin 1
#define AnalogInput_2 A2 //Sensors on Analog pin 2
#define AnalogInput_3 A3 //Sensors on Analog pin 3
//servo motors
Servo servo3;  // create servo object to control a servo
Servo servo5;  // create servo object to control a servo
//Continous servo motor stop speed value
int STOP = 90;
int dig02 = 2;//D2
int dig03 = 3;//D3 or pwm
int dig04 = 4;//D4
int dig05 = 5;//D5  or pwm
//
void setup(void)
{  
  //Possible Baud rates
//  Serial.begin(300);
//  Serial.begin(1200);
//  Serial.begin(2400);
//  Serial.begin(4800);
//  Serial.begin(9600);
//  Serial.begin(14400);
  //Serial.begin(19200);//usb baud rate
//  Serial.begin(28800);
//  Serial.begin(38400);
//  Serial.begin(57600);  //Set Bluetooth Baud Rate (HC-05)
 //Set Bluetooth Baud Rate
  Serial.begin(115200);
  pinMode(dig02, OUTPUT);//D2
  pinMode(dig03, OUTPUT);//D3 or pwm -COMMENT THIS LINE WHEN USING D03 AS SERVO OUTPUT!
  pinMode(dig04, OUTPUT);//D4
  //pinMode(dig05, OUTPUT);//D5  or pwm - UNCOMMENT THIS LINE TO SET D05 AS SERVO OUTPUT!
  //Servos
  //servo3.attach(dig03);  // attaches the servo on pin 3 to servo object - UNCOMMENT THIS LINE TO SET D03 AS SERVO OUTPUT!
  servo5.attach(dig05);  // attaches the servo on pin 5 to the servo object -COMMENT THIS LINE WHEN USING D05 AS DIGITAL OUTPUT!
 
  stopAllServos();//initial motors
}
void loop(void)
{  
  processSerialInput();
}
  /*
  * Check for serial input and then process
  */
  void processSerialInput(){
    char val;
    char del;
    int param1;
    int param2; 
    
      while(Serial.available()){        
            val = Serial.read();
            param1 = Serial.parseInt();            
            param2 = Serial.parseInt();
            del = Serial.read();    
            
        if(val != -1)
        {          
          switch(val)
          {
            case 'e'://Servo 3                     
              //servo3.write(constrain(param1, 0, 180));  
              break;
            case 'f'://Servo 5(D5)
              servo5.write(constrain(param1, 0, 180));  
              break;
            case 'g'://D5              
              //digitalWrite(dig05, param1);
              break;
            case 'k'://D2
              digitalWrite(dig02, param1);
              break; 
            case 'l'://D3
              digitalWrite(dig03, param1);
              break;                       
            case 'm'://Return Analog read on all ports 
               Serial.print("A,");            
               Serial.print(analogRead(AnalogInput_0));                
               Serial.print(","); 
               Serial.print(analogRead(AnalogInput_1));
               Serial.print(","); 
               Serial.print(analogRead(AnalogInput_2)); 
               Serial.print(","); 
               Serial.println(analogRead(AnalogInput_3));    
            break;
            
            case 'o'://D4
              digitalWrite(dig04, param1);   
              break;           
            case 'z':
              Serial.println("B1.3");        
              break;        
          }//end switch block
        }//end if block           
      }//end while loop}
  /*
  * Stop all servo motors and set to zero speed
  */
  void stopAllServos(){
    //servo3.write(constrain(STOP, 0, 180)); 
    servo5.write(constrain(STOP, 0, 180));
  }

Step 2: Solder LED Leads to D2 Output and Ground Connections

Solder the LED short lead Cathode (-) to the GND pad of the Arduino. Solder the LED long lead Anode (+) to the D2 pad of the Arduino.

Step 3: Solder Laser Leads to D3 Output and Ground Connections

Solder the Laser black wire (-) to the GND pad of the Arduino. Solder the Laser red wire (+) to the D3 pad of the Arduino.

Step 4: Thread Solder Coin Battery Holder Leads Through Nozzle

Place the wire leads from the Coin Battery Holder through one of the holes in the Model Rocket Nozzle.

Step 5: Solder Coin Battery Holder Leads to Arduino

  1. Solder the Coin Battery Holder black wire (-) to the GND pad of the Arduino. Solder the Coin Battery Holder red wire (+) to the VIN pad of the Arduino.
  2. Apply electrical tape to insulate the exposed LED leads.

Step 6: Separate Rocoket Model Halves

  1. Install batteries in coin battery holder.
  2. Remove the screw that holds the two halves of the Rocket Model together.

Step 7: Install Electronics Inside Model Rocket Body

  1. Insert the Laser into the hole in the Rocket Nozzle.
  2. Insert the electronic components inside the Starboard half as shown in the picture.

Step 8: Assemble Rocket Model Halves

Rejoin the two halves of the Rocket Model and screw the two halves together with the screw removed in item 2.

Step 9: Send Bluetooth Control Commands in Raspberry Pi Terminal

    1. Turn coin battery holder switch to the on position.
    2. Power on your Raspberry Pi or any other Bluetooth LE Linux device.
    3. Turn on the Bluetooth on your device.
    4. Open a Terminal and type the following command to scan for the Arduino Bluetooth to determine its MAC address.
      • $sudo hcitool lescan
    5. Run the gatttool using the MAC address found in the previous step. Run the following command:
      • $sudo gatttool -b <Device MAC Address goes here> -I (ex. sudo gatttool -b F8:30:02:09:17:EE -I )
    6. Connect to the Arduino Bluetooth by running the following command at the prompt
      • >connect
    7. Send commands to the Rocket to turn on/off the Laser and cockpit LED Turn on output D2 by running the following command at the prompt. This sends the k1,0, string in Hex to the Arduino:
      • >char-write-req 0x0025 6b312c302c0d0a
    8. Turn off output D2 by running the following command at the prompt. This sends the k0,0, string in Hex to the Arduino:
      • >char-write-req 0x0025 6b302c302c0d0a
    9. Turn on output D3 by running the following command at the prompt. This sends the l1,0, string in Hex to the Arduino:
      • >char-write-req 0x0025 6c312c302c0d0a
    10. Turn off output D3 by running the following command at the prompt. This sends the l0,0, string in Hex to the Arduino:
      • >char-write-req 0x0025 6c302c302c0d0a