Arduino Uno with Bluetooth HC-05 is not showing the results from sketches

Hello there,

I have been using this code for my FSR (Force Sensor Resistivity) and Vibration coin motor.

The Arduino Uno has no problem when connecting through USB port as the pressure applied on the FSR, the coin vibration motor will start vibrating after 7 seconds (even though I have preset the time for 10000milliseconds).

But as soon as I connect Arduino Uno with Bluetooth, the serial monitor is still reading the data but the coin vibration motor starts vibrating as soon as I applied force on FSR.

Is there any solution to this problem?

Below is my coding for the FSR and Coin Vibration Motor:

int motorPin = 5; //motor transistor is connected to pin 5
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
unsigned long elapsedTime = 0;
unsigned long onTime = 10000;

void setup(void) {
Serial.begin(9600);
}

void loop(void) {
fsrReading = analogRead(fsrPin);

Serial.println("Analog reading = ");
Serial.println(fsrReading); // print the raw analog reading

if (fsrReading < 1000) {
onTime = millis();
if(onTime>10000)

{

digitalWrite(motorPin, HIGH); //vibrate
delay(1000); // delay one second
digitalWrite(motorPin, LOW); //stop vibrating
delay(1000); //wait 50 seconds.

Serial.println("It's time to exercise ");
}
} else {
digitalWrite(motorPin, LOW); //stop vibrating
}
delay(1000);

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the </> icon above the compose window) to make it easier to read and copy for examination

The sketch that you posted is incomplete and contains no reference to Bluetooth. Did you post the correct sketch and where is the rest of it ?

This looks wrong to me. Pin 0 I associate with D0.
Change the code to #define fsrPin = A0; // the FSR and 10K pulldown are connected to a0

Hi thanks for replying me, actually I’m new to this arduino coding and do you mind sharing me the Bluetooth coding that I’m missing?

Thanks for the head ups!

Your real problem is probably being addressed in reply #4. You don't actually need any special code for Bluetooth. Just connect HC-05 to serial pins 0,1 Rx to Tx and Tx to Rx. It is advisable to have a 1k / 2k voltage divider in Arduino Tx line.

But the main problem is when Im connecting my arduino to laptop with USB port, the vibrator coin will start vibrating after 7 secs after I applied pressure on my FSR sensor (Which is I intend to do). But as soon as I connect my arduino to laptop with HC-05 Bluetooth, my vibrator coin vibrates immediately after I applied pressure pm FSR sensor.

I assume you either intend to ignore the advice in reply #4, or have already proven it is irrelevant, but can't be bothered enlightening the rest of us to that effect.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.