Introduction: Autonomous BB-8 Drive System
This is meant to help current BB-8 builders to put their rolling droid's abilities to the next level. I am currently building a slightly modified model to accommodate for the ultrasonic sensor, but until that is finished, I am posting this because I believe it to be one of the next steps in the BB-8 building community.
It uses an ultrasonic sensor to measure distance, this portion is in the dome. It then sends a signal if the BB-8 approaches an obstacle, and the drive-train reacts accordingly.
In order to configure the bluetooth modules, I have made a separate instructable linked here, for there are many different versions, and they are hard to configure.
https://www.instructables.com/id/Arduino-Bluetooth-...
Let's get started!
Step 1: Parts
1. Breadboard (you could also have two of them)
2. Two Arduino Boards (I am using a nano, and an uno, but I am sure a mega, and some others would work)
If you don't have a lot of arduino, I recommend getting a starter kit.
https://www.amazon.com/Kuman-Project-Complete-Sta...
3. 2 HC-05 Bluetooth Modules (The ZS-040 modules are the best, but any one with a button is convenient w/o is hard)
https://www.amazon.com/Kuman-Project-Complete-Sta... Or, find one on ebay for cheap.
4. Drive System (I have 2 Hi-Technic Servos For This Example)
5. Led's (any color, and size works, but if using small ones, I recommend a resistor)
6. Wires (you will need a lot of these in various colors, and sizes)
Step 2: Wiring
Specific wiring for your bluetooth module can be found in my other tutorial.
https://www.instructables.com/id/Arduino-Bluetooth-...
Arduino 1 (Mine is the nano)
Plug the bluetooth module into the breadboard to the right of the nano.
5v to vcc on bluetooth module
gnd to gnd on bluetooth module
pin d10 to txd on bluetooth module
pin d11 to rxd on bluetooth module
Plug the led into the breadboard.
pin d8 to LED positive
gnd to LED negative
Arduino 2 (Mine is the uno)
Plug the bluetooth module into the breadboard opposite the nano setup.
5v to vcc on bluetooth module
gnd to gnd on bluetooth module
pin d10 to txd on bluetooth module
pin d11 to rxd on bluetooth module
Plug the led into the breadboard.
pin d8 to LED positive
gnd to LED negative
Servo 1:
black wire to gnd
red wire to 5v
yellow wire to pin 5
Servo 2:
black wire to gnd
red wire to 5v
yellow wire to pin 6
Step 3: The Code
To get the bluetooth modules working, go to my other instructable. For BB-8 builds, I recommend assigning by address, not looking for all bluetooth modules due to it defeating the possibility of bluetooth upload.
https://www.instructables.com/id/Arduino-Bluetooth-...
For this config, follow the same set of instructions, and upload the code below.
For the Master: BB-8Dome...
For the Slave: BB-8Drivetrain...
Make sure to turn off the arduino IDE before unplugging the arduinos because if you don't, the code on the master will be dependent on serial comms, and not function without a USB connection.
And there you go! If there are any questions, please post a comment.