Hey all. I'm starting a project and looking for the best and easiest way to monitor 2 proximity signals (magnetic hall sensors), and will let me know when one of the signals stops sending. The signals are High during idle and go LOW during a pulse.
I need to install 3 sensors on a piece of farm machinery.... a 30 ft grain planter to be exact. The first sensor is easy and just lets me know everything is in place and ready. the other 2 sensors are placed monitoring the corners of a square shaft, which will be rotating at the nearly at the same rpm, except when turning a corner, when one shaft will slow down compared to the other. I need to make it where if the chain comes off one of the shafts and it stops rotating, it will turn on a buzzer and and LED, which i have that part figured out.
I already have most of it sketched out, but i'm unsure on how's the best to proceed to watch the 2 signals. I thought about doing a basic timed counter on each shaft, or something similar. I could use a quick example or something to get me started and i should be able to figure it out from there.
Thanks for an help
int rightSideSensor = 2;
int leftSideSensor = 3;
int centerSensor = 4;
int rightRedLed = 5;
int rightGreenLed = 6;
int rightBlueLed = 7;
int leftRedLed = 8;
int leftGreenLed = 9;
int leftBlueLed = 10;
int buzzer = 11;
static bool rightSideRunning = true;
static bool leftSideRunning = true;
static bool centerReady = true;
void setup() {
Serial.begin(115200);
pinMode (rightSideSensor, INPUT);
pinMode (leftSideSensor, INPUT);
pinMode (centerSensor, INPUT);
pinMode (rightRedLed, OUTPUT);
pinMode (rightGreenLed, OUTPUT);
pinMode (rightBlueLed, OUTPUT);
pinMode (leftRedLed, OUTPUT);
pinMode (leftGreenLed, OUTPUT);
pinMode (leftBlueLed, OUTPUT);
pinMode (buzzer, OUTPUT);
}
void loop() {
digitalWrite(rightBlueLed, LOW);
digitalWrite(leftBlueLed, LOW);
digitalWrite(rightRedLed, LOW);
digitalWrite(leftRedLed, LOW);
if (centerReady == false) {
centerNotReady()
}
else {
rightGreenLed, HIGH;
leftGreenLed, HIGH;
}
// code for monitoring 2 proximity sensors ?
}
void (centerNotReady) {
digitalWrite(rightBlueLed, HIGH);
digitalWrite(leftBlueLed, HIGH);
}
void (rightNotWorking) {
for (int r = 0, r < 5, r++) {
digitalWrite (buzzer, LOW);
delay(100);
digitalWrite (buzzer, HIGH);
delay(100);
}
digitalWrite(rightRedLed, HIGH);
}
void (leftNotWorking) {
for (int l = 0, l < 5, l++) {
digitalWrite (buzzer, LOW);
delay(100);
digitalWrite (buzzer, HIGH);
delay(100);
}
digitalWrite(leftRedLed, HIGH);
}