-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfraredSensor.cpp
53 lines (47 loc) · 1.45 KB
/
infraredSensor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/******************************************************************************
* *
* Program : FileLogger *
* *
* FILE : infraredSensor.cpp *
* *
* Date : 28 / 05 / 2021 *
* *
* Programmers : Team Software "TORQ" *
* *
******************************************************************************/
#include "InfraredSensor.h"
InfraredSensor::InfraredSensor(byte m_pin, byte m_led_pin)
{
pin = m_pin;
led_pin = m_led_pin;
state = 0;
}
void InfraredSensor::init()
{
pinMode(pin, INPUT);
pinMode(led_pin, OUTPUT);
}
int InfraredSensor::read_pin()
{
if(digitalRead(pin) == LOW)
return HIGH;
else
return LOW;
}
void InfraredSensor::display_led()
{
if (read_pin() == 1)
{
digitalWrite(led_pin, HIGH);
state = 1;
}
else
{
digitalWrite(led_pin, LOW);
state = 0;
}
}
int InfraredSensor::get_state()
{
return state;
}