Hello everyone.
I am a mechanical engineer but i am working only with sheet metal constructions till now.
Recently i have been in a company with boom barriers for parking etc.
I have build an arduino to show if the barrier are in open or close position using the signal input from the power limits of the barriers control board.
I am trying to find a way to send a signal to the control board of the barrier after a specific time.
Can please someone help me out?
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
byte a[8] = {
0x1f,
0x1f,
0x1f,
0x1f,
0x1f,
0x1f,
0x1f,
0x1f,
};
byte b[8] = {
0x1f,
0x1f,
0x1f,
0x0,
0x0,
0x0,
0x0,
0x0,
};
int bar1Val;
int bar2Val;
int pin1 = A1;
int pin2 = A2;
int bar1State = 0;
int bar2State = 0;
void setup() {
pinMode(pin1, INPUT_PULLUP);
pinMode(pin2, INPUT_PULLUP);
pinMode(9, OUTPUT);
lcd.begin(16, 2);
delay(1000);
lcd.createChar(0, a);
lcd.createChar(1, b);
// delay(2000);
Serial.begin(9600);
}
void loop() {
// analogWrite(9, 550);
bar1Val = analogRead(pin1);
bar2Val = analogRead(pin2);
Serial.print("bar1Val is ");
Serial.println(bar1Val);
Serial.print("bar2Val is ");
Serial.println(bar2Val);
delay(1000);
if (bar1Val > 550 && bar1State == 0) {
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.setCursor(1, 0);
lcd.write(byte(1));
lcd.setCursor(2, 0);
lcd.write(byte(1));
lcd.setCursor(3, 0);
lcd.write(byte(1));
lcd.setCursor(4, 0);
lcd.write(byte(1));
lcd.setCursor(5, 0);
lcd.write(byte(1));
lcd.setCursor(6, 0);
lcd.write(byte(1));
lcd.setCursor(0, 1);
lcd.print("CLOSE ");
bar1State = 1;
}
else if (bar1Val < 250 && bar1State == 1) {
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.setCursor(1, 0);
lcd.write(byte(1));
lcd.setCursor(2, 0);
lcd.write(byte(1));
lcd.setCursor(3, 0);
lcd.write(byte(1));
lcd.setCursor(4, 0);
lcd.write(byte(1));
lcd.setCursor(5, 0);
lcd.write(byte(1));
lcd.setCursor(6, 0);
lcd.write(byte(1));
lcd.setCursor(0, 1);
lcd.print("OPEN ");
bar1State = 0;
}
if (bar2Val > 550 && bar2State == 0) {
lcd.setCursor(9, 0);
lcd.write(byte(1));
lcd.setCursor(10, 0);
lcd.write(byte(1));
lcd.setCursor(11, 0);
lcd.write(byte(1));
lcd.setCursor(12, 0);
lcd.write(byte(1));
lcd.setCursor(13, 0);
lcd.write(byte(1));
lcd.setCursor(14, 0);
lcd.write(byte(1));
lcd.setCursor(15, 0);
lcd.write(byte(0));
lcd.setCursor(0, 1);
lcd.print(" CLOSE ");
bar2State = 1;
}
else if (bar2Val < 250 && bar2State == 1) {
lcd.setCursor(9, 0);
lcd.write(byte(1));
lcd.setCursor(10, 0);
lcd.write(byte(1));
lcd.setCursor(11, 0);
lcd.write(byte(1));
lcd.setCursor(12, 0);
lcd.write(byte(1));
lcd.setCursor(13, 0);
lcd.write(byte(1));
lcd.setCursor(14, 0);
lcd.write(byte(1));
lcd.setCursor(15, 0);
lcd.write(byte(0));
lcd.setCursor(0, 1);
lcd.print(" OPEN ");
bar2State = 0;
}
}
Thank you in advance
Greetings
Leo

