Hi All,
I have successfully connected an Arduino to an RC car, and I can get the PWM (that is sent to the RC car motor) displayed in the serial monitor.
I've connected an XM-15B bluetooth module as per this site
I've opened up another Arduino IDE on the PC, and am selecting one of the two new COM ports that have shown up, after I've set up the Bluetooth module. I just chose any Arduino board, but when I run the serial monitor, nothing shows up. I'm not sure what i'm missing.
What i'm trying to do broadcast the recorded PWM from the RC car, and then read and record it on a PC. I figure if I can just get it to appear in a serial monitor, then I can copy and paste it into a text file. Can arduino create text logs automatically?
I used basic bluetooth code to test the module, so i know its working, and i set its baud to 115200, as well as the serial monitor, and Windows 7 settings.
Here's the code i'm using:
#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(10, 11); // (RX, TX)
volatile int pwm_value = 0;
volatile int prev_time = 0;
void setup() {
Serial.begin(115200);
pinMode(9, OUTPUT); // this pin will pull the XM-15B CE pin HIGH to enable the module
digitalWrite(9, HIGH);
Serial.println("AT Command:");
Bluetooth.begin(115200); // XM-15B default speed
// when pin D2 goes high, call the rising function
attachInterrupt(0, rising, RISING);
}
void loop() {
// read from XM-15B ==> Serial Monitor
if (Bluetooth.available())
Serial.write(Bluetooth.read());
// read from Serial Monitor ==> XM-15B
if (Serial.available())
Bluetooth.write(Serial.read());
delay(20);
}
void rising() {
attachInterrupt(0, falling, FALLING);
prev_time = micros();
}
void falling() {
attachInterrupt(0, rising, RISING);
pwm_value = micros()-prev_time;
Serial.println(pwm_value);
}
Any help would be greatly appreciated!
I'm guessing I might have to have another arduino on the PC end, and another bluetooth module to receive? But my laptop has bluetooth built-in so i don't think I need a second arduino/bluetooth pair.