I've built a small motor circuit, using the arduino Uno rev3, and am able to cycle it on and off manually and with a timer. My goal is to get the motor to respond to a Bluetooth signal sent by a small SEMG device so that it vibrates when the device reads a certain amplitude.
I know that I will need a Bluetooth module (I'm thinking HC-05). The SEMG device sends out a constant signal. Is there anything that I need to know about the SEMG device in regards to setting it up on the Arduino?
I figure the code will be a fairly simple high/low script based on the signal, but I'm not certain. Any help is greatly appreciated.
It will be useful to know the device's Bluetooth protocol. If it is a plain-vanilla SPP device, it should be able to work with an HC-05 and, if it can do that, anything Arduino needs to do will probably be quite straightforward.
#define motorPin 13
int data = 0;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600); //default baud rate for bt 38400
}
void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
data = Serial.read(); // Reads the data from the serial port
if (data == '0') {
digitalWrite(motorPin, LOW); // Turn motor OFF
Serial.println("motor: OFF");
}
else if (data == '1000') {
digitalWrite(motorPin, HIGH);
Serial.println("motor: ON");
}
I see. Thank you. Im guessing I need a BLE shield or an HM-10. Im looking now but all of the modules I see are for phone pairing using a specific app. Im just trying to pair using the UUID for my sensor.
Am I in the right ballpark with the code from above?
The modules are not specifically for phone pairing at all. It is just that that is the most common approach, with the phone acting as master. All that means is that the phone app initiates the connection.
In your case Arduino is the master, i.e. IT initiates the connection, and HM-10 is up to that. Indeed this is surely a simple SPP datastream job, and the so-called "fake" CC2541 HM-10 should be fine. The UUID is essentially the same as an HC-05 MAC address, and does not bring its own problems.
I have little experience with BLE, and you will probably get more enlightenment on the Martyn Currey website.