Hi, this instructable will help you discover(hopefully) how to get two Arduino's receive and send data over Bluetooth.
There will be pictures that are a little blurred, but I felt these are important because thy also show the development of the vehicle as ideas come to the fore., plus....I didn't have auto-focus turned on...duh..
The longest part of the project, because of the amount of trial and error, was the programs/sketches working to communicate at the right baud rates, handshaking and making sure the right codes, numbers and even the characters weren't garbage.
The goal was to get away from using an app, or serial program that needs your phone to communicate to your project.
I used motors and chassis from a motorized clock that spins around when the alarm clock is set.(so now in pieces). I also had to hand a phone suction holder for the front balancing and sticking the IR sensor to it. So it's a bit cobbled together.
I dismantled some battery power packs, so to give me a choice of voltages and power. There are two that are in series giving 8-9 volts @ 1Ah approx. There are another two in parallel that give 3.7-4.5 volts @ 2.4Ah. I also made some adapters so I could mix and match batteries, slight improvements along the way for placing on the bot itself, and they're all rechargeable.
The controller basis I used was from a d-funked calculator, which fits on your hand nicely. The Bluetooth, nano electronics on the underside and number pad stuck to the other. There's another power pack battery on the underside, which can also be re-charged as you would normally.
This project is still a work in progress especially the code, which has loads of potential for it to be sensors and triggers instead of motors and a number pad.
Pictures, video, code to follow........
Step 1: Maddybot Testing
This is one of several parts that I was testing the remote control was working for the bot. It's jacked up so it's not going anywhere for this part. More Maddybot testing to follow.
Step 2: Maddybot Testing Part 2
Here's a vid of more testing on the floor, I didn't cut anything out so it's a bit raw.
Step 3: The Pins and Code for Maddbot Receiving
Ok so there's room for improvement in my program, I left some of the original lines, commented out, so you can see how the program evolved a bit.
Moves are split into functions, so you could play about with what key does what, or a multiple sequence of character codes to perform any actions you like - you'll have do the tinkering on that one tho.
I used an Arduino Uno/Genuino for this construction, it has the wider base and a few more pins to play with. Apart from a couple of mods for turning it on and off, motor plug and Bluetooth placement, the connections to the pins are straight forward when using the Arduino motor shield. The servo and IR detector(power) are on the servo pins as labeled on the board. Bluetooth Rx and Tx are connected to A2 and A3 as digital pins, A1 is the sensor detection, A0 is used just to confirm connection between the to Bluetooth devices. via led.
When setting up the Bluetooth for both the MaddyBot Receiver and Remote Sender, they need to be setup as slave and master respectively. It can be a bit nightmare-ish getting that bit done, so patience is more than a virtue.
This part was relatively straight forwardish programming, next the code for the sender.....
Step 4: The Pin Details and Code for Maddybot Sending
Thanks to contributions from examples and elsewhere(noted in program), this is the program for sending from the remote keypad.
I'm using an Arduino Nano, because somehow I buggered up the USB port(I think I shorted it, in my experiments), so I directly connect to D0 and D1 to upload my code, not forgetting to keep reset low and release when IDE says uploading to board. Bluetooth is on D10 as Tx and D11 as Rx. Keypad is straight on D2-D9.
One thing to check at least is that if your Bluetooth isn't communicating, try swapping Rx and Tx, If you have your serial USB port still intact(like I haven't) then uploading to the Arduino via USB is as usual.
I think that about wraps it up, any quessies welcomed.