Electric Longboard Bluetooth Control

Hi there,

I am a relative noob to arduino and just got myself an uno. I know some of the basics of the language but I don;t know enough to do this project.

Project Outline:
I have built an electric longboard that uses an ESC to drive a motor that powers the longboard. I could use a conventional rc controller but they are too bulky. I would like to use my android phone to control it via bluetooth. So essentially I need help in writing some arduino code to receive a number (between 0 and 100) via the bluetooth link and adjust the speed of the motor acordingly (from stopped to max speed)

So Far:
I have purchased a bluetooth module (http://www.ebay.co.uk/itm/131254199767) which I believe is compatible with both arduino and my phone.
I have also made an app according to some instructions I found online that were aimed at controlling a servo and so should transmit an integer from 0 to 100 across the bluetooth link. I am not even sure if it works though… I have attached images of the app i made in MIT inventor.

I really need help…thanks in advance,

Nick :slight_smile:

bump

Did you ask a question.

He did

and I just bumped it for him

Nickolae:
essentially I need help in writing some arduino code to receive a number (between 0 and 100) via the bluetooth link and adjust the speed of the motor acordingly (from stopped to max speed)

thanks, yeh essentially I just need some code that will support the bluetooth module and allow my phone to connect to it and drive the ESC. I know it's quite rude of me just to ask someone to write it for me but I have been trying for ages and it is mega frustrating...

I know what you mean. got into this stuff with a specific project in mind also.

I'm pretty decent with the electronics but am still struggling with the programming.

doubt you will find anyone to write your sketch for you. it's better to do as many tutorials as you can find and there are a lot of them. Also I would start by getting a simple piece of your program working and then building on that till you get where you want to be.

try getting the arduino to control the motor by itself before you try to add bluetooth. take baby steps and you will eventually get there.

sounds like a plan :)

Okay, So I have made some progress and can now get the ESC to run and be controlled by the Uno. The next issue I am having is getting the bluetooth signal to control the ESC. This is the code I have so far, can anyone see any obvious issues with this. If not then perhaps it is the app that isn’t behaving…

my circuit is with the signal pin of ESC connected to pin 9, and its ground grounded. I have the bluetooth module powered by 3.3v and it has a ground connection and its RX pin connected to the RX pin on the uno.

#include <SoftwareSerial.h>// import the serial library
#include <Servo.h>
SoftwareSerial Bluetooth(10, 11); // RX, TX
int BluetoothData; // the data given from Computer
Servo ESC;

void setup() {
// put your setup code here, to run once:
Bluetooth.begin(9600);
Serial.println(“Bluetooth On”);
ESC.attach(9);

}

void loop() {
// put your main code here, to run repeatedly:
if (Bluetooth.available()){
BluetoothData=Bluetooth.read();
ESC.write(BluetoothData);
Serial.println(BluetoothData);

}

delay(5);
}

First, remove the delay(). Motor control is hard enough without big delays.

OK, so the bluetooth appears as a serial device. Do you know if it's sending bytes or ASCII? What are you seeing as the result of your Serial.println(BluetoothData)?

Your code looks like it should work if the bluetooth is sending only bytes in the range 0-255 and no other characters. What range of values is the servo expecting?

Okay, have removed the delay.

It should be sending bytes, but if you look at one of the images attached it uses the "send 1 byte number" command in the app so it should be bytes with a value ranging from 0-100, but that could be changed. I'm using a slider in the app to give an output to control the motor.

I'm not getting anything in my serial monitior, not even the Serial.println("Bluetooth On")...

at the moment, 0-100 (the output form the app) but I will change it to 0-180 because that is the range that the esc accepts.

There's no Serial.begin() in your code.

Ah, okay, thanks, now I have bluetooth on coming up but when i move the slider back and forth im gettiing nothing on the serial monitor at all

Okay now when i move the slider on the app, series of random symbols and letters and numbers comes up on the monitor..?

got it working!!!