Arduino Bluetooth & FSR

Hi! Newbie here, no programming experience… I’m trying to write a code to turn the bluetooth on or off based on an input from an FSR. Basically, while a force is applied to the FSR, bluetooth will turn on and able to connect to a phone. Here is the code I’ve written, please advise. Thanks!!

SoftwareSerial BT(0, 1);
String command;
int PressurePin=A0;
int force;
void setup() {

pinMode (PressurePin, INPUT);


void loop() {
force=analogRead (PressurePin);

while (force>500) {



I have no idea of what you are trying to do, or what an FSR might be, but your code is junk in that you are calling for the software serial library but you are not using it. This is just as well because you are also nominating it on the hardware serial pins 0,1. which would be fatal anyway. If you delete all reference to software serial, BT., and ensure that Bluetooth is disconnected while you upload your programme, you might get a result.

You can test that your programme is kosher by reading the data on the serial monitor before reconnecting Bluetooth.

An FSR is a Force Sensitive Resistor. I want to make it so that only when pressure is applied to the FSR, bluetooth will turn on. Sorry if the code is junk, I don't really understand the commands, I kind of just grabbed parts of similar codes I found online. Should I connect the Bluetooth module to ports 2&3 instead?

Should I connect the Bluetooth module to ports 2&3 instead?

I would be inclined to stay with 0,1 and get rid of software serial as I said. Assuming that by "turn on" you really mean "send data", sticking with pins 0,1 will enable you to test the programme as I described - without Bluetooth even being connected. Once proven, the programme can be used with Bluetooth, without modification.

You might find the following background notes useful.