Hi! Are there any suggestions about how to connect a force sensitive resistor (FSR) together with a HC-05 bluetooth module to a Arduino Nano via a breadboard? We wish to obtain real time data from the FSR with an Android app that is connected to the HC-05.
So far, we've managed to connect the FSR to the Arduino Nano and the HC-05 to the Arduino Nano individually. Here are the setups we've done and the codes we've used:
FSR set up: Fritzing/schematic diagram
FSR code:
int fsrPin_In = A0;
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
analogRead(fsrPin_In);
Serial.print("Analog reading = ");
Serial.print(analogRead(fsrPin_In));
if (analogRead(fsrPin_In) < 10){
Serial.println(" NO PRESSURE");
} else if (analogRead(fsrPin_In) < 100){
Serial.println(" LIGHT TOUCH");
} else if (analogRead(fsrPin_In) < 200){
Serial.println (" LIGHT SQUEEZE");
} else if (analogRead(fsrPin_In) < 300){
Serial.println (" MEDIUM TOUCH");
} else if (analogRead(fsrPin_In) < 500){
Serial.println (" MEDIUM SQUEEZE");
} else if (analogRead(fsrPin_In) <800){
Serial.println (" BIG TOUCH");
} else {
Serial.println(" BIG SQUEEZE");
}
delay(1000);
}
HC-05 set up: here
HC-05 code:
// Basic Bluetooth sketch HC-05_02
// Connect the HC-05 module and communicate using the serial monitor
//
// The HC-05 defaults to commincation mode when first powered on.
// The default baud rate for communication mode is 9600
//
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
//
char c = ' ';
void setup()
{
Serial.begin(9600);
Serial.println("Arduino is ready");
// HC-05 default serial speed for commincation mode is 9600
BTserial.begin(9600);
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
{
c = Serial.read();
BTserial.write(c);
}
}
How do we combine the two set ups and the two code? Fritzing/schematic diagrams would be helpful. Thanks!