photo resistor with bluetooth

Hi all,

I’m very new to Arduino and i’m having some issues with getting this code to work, so basically i’m just tinkering and getting used to bluetooth control with different sensors. This project is a 3 way laser trip wire (3 lasers and 3 photo resistors) and being able to activate each laser independently eg: laser 1+3 or 2+1 or 1,2+3 via bluetooth and return a message to the app to tell me which laser beam has been broken, i already have the app designed so all good there, it just wont do what i want it to do, i get the right result when the laser is on or off the photoresistor upon pressing the button on the app but i keep having to press the button on the app to reset it when i want it to run independently to the laser selection ie activate the laser then read when the laser has been broken , i think im having a curly bracket issue like i said i’m very new to arduino i am learning as i go but any help or guidance would be gratefully appreciated.
Thank you all

 #include <SoftwareSerial.h>
#include <LiquidCrystal.h>
SoftwareSerial BT(10, 9); // RX, TX
String readString;

int laserOne = 2;
int ledOne = 3;
int photoOne = A0;
int photoOneVal;
int photoOneCal;
int laserTwo = 5;
int ledTwo = 6;
int photoTwo = 7;
int laserThree = 8;
int ledThree = 11;
int photoThree = 12;

void setup() {

   pinMode(laserOne, OUTPUT);
   pinMode(ledOne , OUTPUT);
   pinMode(photoOne, INPUT);
   pinMode(laserTwo, OUTPUT);
   pinMode(ledTwo , OUTPUT);
   pinMode(photoTwo, INPUT);
   pinMode(laserThree, OUTPUT);
   pinMode(ledThree , OUTPUT);
   pinMode(photoThree, INPUT);
   digitalWrite(laserOne, HIGH);
void loop() {
   photoOneVal = analogRead(A0);
 if (readString =="LASER 1"){
  digitalWrite(ledOne, HIGH); 
 if (photoOneVal < 700){
  Serial.println("laser 1 triggered");

welcome to the forums.

+1 karma for using code tags when posting your code.

Your code is doing exactly what you told it to do. You try reading in a message from BTl You then check the length of the message and if it is greater than 1, you report the laser and then set the string back to zero.

So the next time through loop(), there is no BT message, the length is 0 so your entire if() statement is skipped meaning you don’t print anything.

Exactly how to you want it to react? Report every time through loop()? That will give you hundreds of messages per second.

Also, you define ‘photoOne’ to be A0, but then do an anlaogRead() using A0. It is better to actually use the variable so if you change your setup, it will still work

const byte photoOnePin = A0;
  photoOneVal = analogRead(photoOnePin);