Help a New guy Please

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

What format is the signal that you need to send, and what method of receiving such signal does the control board support?

I just need to trigger the control panel to close the barrier after lets say 10secs.
Control panel is using 12v input / output.
I have connect oto arduino a step down (i think its called) in order to give to arduino less than 5 volt.
Right now the code is working great.
I just need to add to the code, that when the barriers are in on position to send a signal through a pin of the arduino to the control panel in order to close the barrier.
I hope i make it clear :o

PS throught the voltage that i am receiving through the control panel of the barrier i can understand if the barrier is open or closed

What signal to the control panel triggers close?

Control Panel needs just an instantly a 5v signal.

Most arduinos run on 5v. Just connect a pin and write HIGH to supply 5v. Check current and need for pull down resistor. If it is >40mA then use a transistor or similar to drive from separate supply but presume it is logic level signal

Does it need to be for a certain minimum and / or maximum duration, or can it be as short or as long as you like, or does it (for example) need to stay until some other event, or... or... or?

Can you please let me know what to write?
Everything i have write till now is through 2 days of work :smiley: I said... i am totally out of my area...
Another thing... i will
It needs to be a short signal

Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.

Can you explain what you believe this is doing? It looks like complete nonsense. Have you tested it? You should have 100% working code before you think about adding new features.

Also, you have no comments in your program at all, you only used it to disable code. That is not good.

You can never go wrong by isolating the Arduino microcontroller from remote power. Two common ways are opto-isolation and relays. Everything you need to know about relays with example code is here:
Arduino - Relay Shield | Arduino Tutorial (arduinogetstarted.com)

You should not be posting now. You should be editing your post an putting code tags in, as requested.

I am not really sure. But i use it to create special lets say characters.
So i use those characters on the 1st row of the lcd screen to display something that looks like a barrier.
The display shows what i was trying to show. And code works correctly.
When there are in open position i get low voltage in arduino input show it show that barrier is on.
And the opposite.

Please go back and read the forum guidelines that you skipped over. Then post the schematics.

Only because 'byte(0)' and '0' are exactly equivalent in this case. But the typecast to 'byte' is unnecessary and confusing.

It is indeed correct that our guidelines ask for this information, but in this very specific post by a CE who achieved a rather clever solution to a problem and is only asking a specific question about output, I think it may be overkill. It seems to me that a direct answer, an option, and relevant url-link is all that is required and gets the inquiry answered quickly and accurately.

But, just my opinion.

Ray

Good catch.


In my experience here, and especially with the characteristics of the information provided, such a direct answer is not likely to hit the target. Especially as the method of control of the device mentioned is extremely vague. The requests for information that the forum introduction makes, and which I frequently reinforce with posted requests, very often shorten the time that it takes to arrive at a practical solution, and improve the quality of the solution. That is regardless of whether I happen to be the provider of that solution, or it is some other forum member.

Just look at what we got for asking - photos of a wire jungle with tape covering things. That is marginally better than nothing at all. No details of the "control board" at all. This is not coming from a 10 year old STEM student, it is purportedly coming from an engineer.

How do you know what this "control board" is, or what control signal should drive it?

Don’t see a wire on A2 ?


For analog inputs you do not need these 2 lines of code:

  pinMode(pin1, INPUT_PULLUP);
  pinMode(pin2, INPUT_PULLUP);

Always show us a good schematic of your proposed circuit.