Hi All
I am using Mega 2560 for this project
I am fairly new to this so apologise for coding if a mess
I am trying to do a project where LED strip runs after a certain condition is met
When temperature is plus or minus set point = light up all LED strip
When temperature is plus or minus set point = light up all LED strip and start Radio
When movement is detected = light up LED strip in certain colours
All above works fine it's not perfect but for what i need it's fine.
The problem i am having is when i try to use movement sensors it makes the reaction time so slow
the rest take 5 or more seconds to do anything, so everything is delayed until then.
As soon as i disable the sensor code everything runs perfect i have tried to use an Array, and also do the functions a separate functions for sensor movement
I have spent a month solid trying to solve this without help but i can't solve this, could someone point me in the right direction please?
Part 1 of code
Thanks
Peter
#include <TEA5767Radio.h>
#include <Adafruit_NeoPixel.h>
#include <Button.h>
#include <Wire.h>
#include "SparkFunBME280.h" // temp sensor
#include <LiquidCrystal_I2C.h>
TEA5767Radio radio = TEA5767Radio();
#define PIXELS 572 // Number of NeoPixels
#define PIN 3 // pin on the Arduino is connected to pin 3 for NeoPixels
#define Radio 40 // Mosfet Pin
#define Fsensor 4
#define Bsensor 5
#define Lsensor 6
#define Rsensor 7
//---< Neo Pixels >---//
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXELS, PIN, NEO_GRB + NEO_KHZ800);
//---< Temp Sensor >---//
BME280 mySensor ; //Uses I2C address 0x76 (jumper closed) // temp sensor
// set the LCD address to 0x27 for a 20 chars 4 line display
LiquidCrystal_I2C lcd (0x27, 20, 4);
/*-----( Declare Variables )-----*/
// const int chipSelect = 4;
// int SensorsPinArray [4] = {4, 5, 6, 7}; // Array for Microwave Sensor PINS //
Button button1(24); // Connect your button between pin number and GND
Button button2(25); // Connect your button between pin number and GND
int alarmTemp = 77; // starting set point for temp adjustments
//int alarmTempLow = 77; // starting set point for temp adjustments
void setup() {
// Serial.begin(9600); // Used to enable Print data to serial port 9600 is port speed
button1.begin(); // Used to Higher Temp
button2.begin(); // Used to Lower Temp
lcd.init(); // initialize the lcd
lcd.backlight(); //Backlight ON if under program control
pinMode(Radio, OUTPUT); // Radio control pin as output
digitalWrite(Radio, HIGH); // Turn the radio On
pinMode(Fsensor, INPUT); // Sensor pin
pinMode(Bsensor, INPUT); // Sensor pin
pinMode(Lsensor, INPUT); // Sensor pin
pinMode(Rsensor, INPUT); // Sensor pin
// pinMode(SensorsPinArray, INPUT);
strip.begin(); // Neo Pixels Begin
strip.setBrightness(10); // Brightness control for Neo Pixels
Wire.begin();
mySensor.setI2CAddress(0x76); //Connect I2C sensor
mySensor.beginI2C();
lcd.init(); // initialize the lcd
lcd.backlight(); //Backlight ON if under program control
}
Ghost Box Sensors-Radio-Buttons-Temp-lcd backup V16 ext Power working but slow.txt (8.08 KB)