-
Notifications
You must be signed in to change notification settings - Fork 0
/
BinLED.cpp
executable file
·40 lines (35 loc) · 862 Bytes
/
BinLED.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
/*
* BinLED.cpp
*
* Created on: Sep 21, 2021
* Author: victor.wheeler
*/
#include "BinLED.h"
BinLED::BinLED(int pin) {
led = pin;
state = true;
debug = true;
Serial.print(F("LED_BUILTIN "));
Serial.print(LED_BUILTIN);
Serial.print(F("\tOUTPUT "));
Serial.println(OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
pinMode(led, OUTPUT);
digitalWrite(led, 0);
}
bool BinLED::toggle() {
set_State(!state);
return state;
}
void BinLED::set_State(bool state) {
this->state = state;
if (state) {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
if (debug)
Serial.print(F("ON "));
} else {
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
if (debug)
Serial.print(F("OFF "));
}
}