SmartBox-Sortic
SmartFactory
SensorArray.cpp
Go to the documentation of this file.
1 
19 #include "SensorArray.h"
20 
21 SensorArray::SensorArray(const int Sensor1, const int Sensor2, const int Sensor3, const int LoadIndicatorLED) : pSensor1(Sensor1),
22  pSensor2(Sensor2),
23  pSensor3(Sensor3),
24  pLoadIndicatorLED(LoadIndicatorLED) {
25  pinMode(pSensor1, INPUT);
26  pinMode(pSensor2, INPUT);
27  pinMode(pSensor3, INPUT);
28  pinMode(pLoadIndicatorLED, OUTPUT);
29 }
30 
34 bool SensorArray::getSensorData() { // read sensor, true if full
35  DBFUNCCALL("SensorArray::getSensorData()");
36  DBINFO3("getting Sensor Data");
37  int sensor1 = !digitalRead(pSensor1); // if Object detected PIN = LOW
38  int sensor2 = !digitalRead(pSensor2);
39  int sensor3 = !digitalRead(pSensor3);
40 
41  DBINFO3("SensorValue1: " + String(sensor1));
42  DBINFO3("SensorValue2: " + String(sensor2));
43  DBINFO3("SensorValue3: " + String(sensor3));
44  if (sensor1 || sensor2 || sensor3) {
45  DBINFO3("Sensor found Element in Box"); // true if within 0.5-5cm from Sensor, otherwise false
46  // digitalWrite(LOADINDICATOR_LED, HIGH);
47  return true;
48  } else {
49  DBINFO3("Sensor found no Element");
50  // digitalWrite(LOADINDICATOR_LED, LOW);
51  return false;
52  }
53 }
54 
55 //===================================PRIVATE======================================================================
SensorArray(const int Sensor1, const int Sensor2, const int Sensor3, const int LoadIndicatorLED)
Construct a new Sensor Array object.
Definition: SensorArray.cpp:21
bool getSensorData()
Read the Sensor Values.
Definition: SensorArray.cpp:34
const int pLoadIndicatorLED
Pin for loadindicator LED.
Definition: SensorArray.h:54
#define DBFUNCCALL(x)
const int pSensor3
Pin LevelDetector 3.
Definition: SensorArray.h:53
const int pSensor1
Pin LevelDetector 1.
Definition: SensorArray.h:51
#define DBINFO3(x)
The Sensor Array detects the box fill level.
const int pSensor2
Pin LevelDetector 2.
Definition: SensorArray.h:52