#include <Adafruit_NeoPixel.h>
//CONFIG CLOCK
#define IS_SET_CLOCK_ON 0
#define CLOCK_MIN 53
#define CLOCK_HOUR 13
#define CLOCK_DAY 31
#define CLOCK_MONTH 12
#define CLOCK_YEAR 23
#define CLOCK_WEEKDAY 1
// CONFIG TURNSTILE
#define INVERSE_SENSOR 1 // Sensor inverce 0/1
#define IS_IMPULSE true // Impulse relay control = true/false
#define WAITING_PASS 7 // Pass Waiting time
#define TIME_OF_IMPULSE 700 // Open impulse time
#define PIN_SENSOR_1 A0 // sensor pin (A0/A1)
#define PIN_RELAY_E1 8 // pin relay electromagnethic
#define QR_KEY "icecold" // Password key
// CONFIG ICE SESSION
#define SESSION_DELTA_MIN 10 // Count of min for early pass
#define SESSION_DURATION 90 // Count of min for early pass
// CONFIG DISPLAY
#define TIME_SHOW_MESSAGE 2000 // Message display time
//LED
#define PIN_LED 9
#define NUM_LED 5
#define LED_INTENSITY 250
#define AMBIENT_INTENSITY 1
#define BARCODE_SERIAL Serial // Port barcode scanner
#define BARCODE_SPEED 9600 // Speed barcode port
#define LOG_SERIAL Serial // Port for logs
#define LOG_ON 0 // Is log on? 0 = off
#define BUTTON_1 2 // Pin button
#define BUTTON_2 3 // Pin button
#define BUTONN_3 4 // Pin button
// GLOBAL VARIABLES
String qrCode = "";
int8_t ticketType = 0;
uint64_t timerClock = millis();
uint8_t jColor = 0;
bool isJColorPlus = true;
//LED
Adafruit_NeoPixel led(NUM_LED, PIN_LED, NEO_GRB + NEO_KHZ800);
uint8_t ambientIntence = 255;
uint8_t ambientR = ambient_intence;
uint8_t ambientG = 0;
uint8_t ambientB = 0;
// START SETUP ---------------------------------------------------------------------------------------------------
void setup() {
//Init led
led.begin();
//Init relay
pinMode(PIN_RELAY_E1, OUTPUT);
// Init sensor
pinMode(PIN_SENSOR_1, INPUT_PULLUP);
// Init Barcode
BARCODE_SERIAL.begin(BARCODE_SPEED);
}
void loop() {
ambient();
//rainbow(20);
delay(100);
}
void logWrite(String message){
if(LOG_ON){
LOG_SERIAL.println(message);
}
}
void ambient() {
ambientR
if(ambientR >= ambientIntence){
ambientR--;
ambientG++;
}else if(ambientG >= ambientIntence){
}
for(i=0; i<led.numPixels(); i++){
led.setPixelColor(ambient_r, g, b);
}
led.show();
}
void ledNeoPixelOn(boolean r, boolean g, boolean b){
led.clear();
for(int i=0; i<NUM_LED; i++) {
led.setPixelColor(i, led.Color(r*LED_INTENSITY, g*LED_INTENSITY, b*LED_INTENSITY));
}
led.show();
}
void rainbow(uint8_t wait) {
uint16_t i;
if(jColor == 0){
isJColorPlus = true;
}else if(jColor == 255){
isJColorPlus = false;
}
if(isJColorPlus){
jColor++;
}else{
jColor--;
}
for(i=0; i<led.numPixels(); i++) {
led.setPixelColor(i, Wheel((i+jColor) & 255));
}
led.show();
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
float intency = AMBIENT_INTENSITY;
uint8_t intence = 55;
WheelPos = intence - WheelPos;
if(WheelPos < 85) {
return led.Color(int(intence - WheelPos * 3 * intency), 0, int(WheelPos * 3 * intency));
}
if(WheelPos < 170) {
WheelPos -= 85;
return led.Color(0, int(WheelPos * 3 * intency), int(intence - WheelPos * 3 * intency));
}
WheelPos -= 170;
return led.Color(int(WheelPos * 3 * intency), int(intence - WheelPos * 3 * intency), 0);
}