Go Down

Topic: Help with sensor reading sent to app via Bluetooth (Read 607 times) previous topic - next topic

Questioner01

Hi,

I want to send FSR sensor readings to an app and do it with the help from a Bluetooth module (HC-05). I have the following code for the FSR reading (including an LED that turns on/off):

int fsrPin = 0;
int LEDpin = 11;
int fsrReading;
int LEDbrightness;

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

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

Serial.print("Analog reading = ");
Serial.print(fsrReading);


if (fsrReading < 10) {
Serial.println(" - No pressure");
} else if (fsrReading < 200) {
Serial.println(" - Light");
} else if (fsrReading < 500) {
Serial.println(" - Light");
} else if (fsrReading < 800) {
Serial.println(" - Medium");
} else {
Serial.println(" - High");
}


LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
// LED gets brighter the harder you press
analogWrite(LEDpin, LEDbrightness);

delay(1000);
}

and as mentioned, I want to use the HC-05. I connect its RX-->TX and its TX--> RX, then connect it to the 5 V (dividing it with a resistor) and one to ground. I found the following code for the module

https://exploreembedded.com/wiki/Setting_up_Bluetooth_HC-05_with_Arduino

Now, here is the question. Where in my own code should I include his code? I have tried different ways and get an error.  :smiley-confuse:   Maybe you can suggest a code? Any help is appreciated!

Thanks!


Go Up