@groundFungus , hi! thank you for your help... means a lot...as it is my firs project
The sketch that you've corrected works great.
It is a part of a project. I suppose to write a program that will read data from an LDR and a thermistor( don't know the actual types as it came in a kit, the most basic ones I suppose).
The sketch should contain two main functions:
- Automatic Dawn to Dusk Light with manual override.
- Room temperature controller with manual override and high temperature alarm.
The sketch should work out data and display it in the app:
LDR ->light levels in Lux
Thermistor -> temperature in Centigrade
It should work in auto mode but allow switching it to manual mode
I've created functions for every operation and separately each works fine, but all together...
Al functions send data via serial ports ...
sprintf(Str, "D%d\n", lux);
Now that I've "piled" up all in one prgram..it doesn't work again....phhh... NUB, what can i say...
Here is the sketch:
int whiteLED = 13;
int blueLED = 7;
int greenLED = 6;
int redLED = 5;
int buzzer = 4;
int thermistor_Data = A1;
int LDR_Data = A0;
char BLData; //Variable to receive data
char Str;//Variable to send data
SoftwareSerial bt(9, 8); // pin 9 (RX) to HC05 TX,
// pin 8 (TX) to HC05 RX through voltage divider
pinMode(whiteLED, OUTPUT);// pin 13 as output
pinMode(blueLED, OUTPUT);// pin 7 as output
pinMode(greenLED, OUTPUT);// pin 6 as output
pinMode(redLED, OUTPUT);// pin 5 as an output
pinMode(buzzer, OUTPUT);//pin 4 as an output
Serial.begin(9600);//Start serial communication
bt.begin(9600); // HC05 serial communication default baud rate
int lux = light_LUX();
int temp = tempC();
bool state = 0; // variable for first status
sprintf(Str, "D%d\n", lux); //the block that displays light measurement and temperature
Serial.write(Str); //inthe app
sprintf(Str, "G%d\n", temp);
if (bt.available())//the block that allow to toggle modes auto/manual
if (reading != lastreading)
if (lastreading == 'Y')
state = !state;
// bt.print("Auto Mode "); bt.println(state);
// bt.print("Manual Mode "); bt.println(!state);
lastreading = reading;