Simple push button RS232 command push

Hello,

So I have a need to change a VTC systems IP configuration. I thought an Arduino would be a perfect fit, but I am new to this and getting off to a rough start. I believe my concept is easy enough, just don't know the best way to do it.

Situation: Video Teleconferencing System moves from one location to another. The user keeps making mistakes when configuring the system. Then needs onsite help.

Solution: Use Arduino and configure 3 different IP configurations that are delivered to the VTC system via RS232. All user needs to do is push a button, or turn a switch to trigger the commands to be sent.

Button one:
Command to be sent: xCommand SystemUnit FactoryReset Confirm: Confirm Yes

Button two:
Network 1 Configuration commands:
xConfiguration Network 1 IPv4 Address: "0.0.0.0"
xConfiguration Network 1 IPv4 SubnetMask: "0.0.0.0"
xConfiguration Network 1 IPv4 Gateway: "0.0.0.0"

Button Three:
Network 1 Configuration commands:
xConfiguration Network 1 IPv4 Address: "0.0.0.0"
xConfiguration Network 1 IPv4 SubnetMask: "0.0.0.0"
xConfiguration Network 1 IPv4 Gateway: "0.0.0.0"

Button Four:
Network 1 Configuration commands:
xConfiguration Network 1 IPv4 Address: "0.0.0.0"
xConfiguration Network 1 IPv4 SubnetMask: "0.0.0.0"
xConfiguration Network 1 IPv4 Gateway: "0.0.0.0"

There will be other configurations, but this will start the process.

Can anyone help push me in the right direction?
Thanks!

Welcome to the forums. I would suggest you get an Uno and try some of the basic examples that come with the IDE (File->Examples->...). Get the Blink sketch working! Look at the button examples and figure out how you need to wire up a button correctly and make sure you can have 4 buttons working. Look at the StateChangeDetection example. It will show you how to figure out when a button is pressed vs. just knowing if the button is currently pressed or not.

Then, since you need to communicate using RS232, you should get an RS232 shield. It will come with examples. Test them out and get communication working with your equipment.

When you get stuck, come back to the forums, read the sticky post at the top of the forum and then post your code (using code tags) along with any errors, and people can help you.

Thanks for the response. I did buy a UNO kit and was working through the projects trying to concentrate on the buttons and rs232. Thanks for the info on the rs232 shield that will be handy, if I do get this working, I will need to put it in a box and that will help.

Yours is a curious problem.
While not offering a solution immediately, I can’t help thinking there is a much simpler, more elegant strategy waiting in the shadows.

Changing the status IP every time you relocate seems a bit tedious.

If you have access to a private VPN (check your routers), that would easily address everything with one time setup. Just plug the phone in at one of your endpoints and go.

It's three different networks, three sets of rules, three different missions. One network does not touch another. Yes, you are right a simple VPN would work for most people. Not me :frowning:

Still curious.
Three networks - check.
Three rules - please elaborate.
Three missions - ditto.

Isn’t this just a phone (or anything) at a remote office?
Shared LAN segment from home office via VPN endpoint, separate remote segment of home office LAN located at outside premises.
Home router firewall configured for IP-VoIP traffic to phone or PBX (VPN) subnet.

IP phone with preconfigured static address on home office VPN segment.
Walk-in anywhere that has VPN client for home LAN segment on local LAN.
Wait 5 seconds.
Ready to go.

I understand the curiosity.

First network. Two use static IPs for video devices one is DHCP.
Each network uses its own gatekeeper or VCS.
Each network requires me to change the name of the device to represent that network.

It goes on and on. It's three networks that have different missions. One doe not talk to the other.

So I did spend some time this morning working on it. Mostly researching what I think is the best and simplest way forward. What I came up with is button push and if/else.

I just don't know what I am doing :slight_smile:

This is what I have put together so far.

void setup() {
  // put your setup code here, to run once:
  
int button = 2;
int button = 3;
int button = 4;
int button = 5;


Void setup () {


// initialize serial communication:
Serial.begin (115200);


pinMode(button, INPUT);
pinMode(button, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
if(digitalRead(button)  == HIGH ){
digitalwrite(, HIGH) ;
}
else {
digitalwrite(??????, LOW);


//Read the button
int button = digital read


// Send a serial string 


Case 0:  // position one of a four position rotary switch
Serial.println (“xConfiguration Network 1 IPv4 Assignment:Static”)
Serial.println (“xConfiguration Network 1 IPv4 Address: "0.0.0.0")
Serial.println (“xConfiguration Network 1 IPv4 SubnetMask: "255.255.255.0")
Serial.println (“xConfiguration Network 1 IPv4 Gateway: "0.0.0.256")
break;


Case 1:  // position one of a four position rotary switch
Serial.println (“xConfiguration Network 1 IPv4 Assignment:Static”)
Serial.println (“xConfiguration Network 1 IPv4 Address: "1.1.1.1")
Serial.println (“xConfiguration Network 1 IPv4 SubnetMask: "255.255.255.0")
Serial.println (“xConfiguration Network 1 IPv4 Gateway: "0.0.0.256")
break;


Case 2:  // position one of a four position rotary switch
Serial.println (“xConfiguration Network 1 IPv4 Assignment:Static”)
Serial.println (“xConfiguration Network 1 IPv4 Address: "2.2.2.2")
Serial.println (“xConfiguration Network 1 IPv4 SubnetMask: "255.255.255.0")
Serial.println (“xConfiguration Network 1 IPv4 Gateway: "0.0.0.256")
break;




Case 3:  // position one of a four position rotary switch
Serial.println (“xConfiguration Network 1 IPv4 Assignment:Static”)
Serial.println (“xConfiguration Network 1 IPv4 Address: "3.3.3.3")
Serial.println (“xConfiguration Network 1 IPv4 SubnetMask: "255.255.255.0")
Serial.println (“xConfiguration Network 1 IPv4 Gateway: "0.0.0.256")
break;

}

It is best to start with code that will actually compile and slowly build it up, always testing it. This code is pretty straight forward and will get you going...

const int button1 = 2;
const int button2 = 3;
const int button3 = 4;
const int button4 = 5;

int lastState1, lastState2, lastState3, lastState4;

void setup() {
  // put your setup code here, to run once:

  // wire your buttons up with one side connected to ground
  // and the other side connected to the input pin
  
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(button3, INPUT_PULLUP);
  pinMode(button4, INPUT_PULLUP);

  // initialize serial communication:
  Serial.begin(115200);
  Serial.println( "Ready" );
}

void loop() {
  // put your main code here, to run repeatedly:
  int state = digitalRead(button1);
  if (state != lastState1 ) {
    if ( state == LOW ) {
      // Send a serial string
      Serial.println("xConfiguration Network 1 IPv4 Assignment:Static");
      Serial.println("xConfiguration Network 1 IPv4 Address: 0.0.0.0");
      Serial.println("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.0");
      Serial.println("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
    }
    lastState1 = state;
    delay(20);
  }

  state = digitalRead(button2);
  if (state != lastState2 ) {
    if ( state == LOW ) {
      Serial.println("xConfiguration Network 1 IPv4 Assignment: Static");
      Serial.println("xConfiguration Network 1 IPv4 Address: 1.1.1.1");
      Serial.println("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.0");
      Serial.println("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
    }
    lastState2 = state;
    delay(20);
  }

  state = digitalRead(button3);
  if (state != lastState3 ) {
    if ( state == LOW ) {
      Serial.println ("xConfiguration Network 1 IPv4 Assignment: Static");
      Serial.println ("xConfiguration Network 1 IPv4 Address: 2.2.2.2");
      Serial.println ("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.0");
      Serial.println ("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
    }
    lastState3 = state;
    delay(20);
  }

  state = digitalRead(button4);
  if (state != lastState4 ) {
    if ( state == LOW ) {
      Serial.println ("xConfiguration Network 1 IPv4 Assignment: Static");
      Serial.println ("xConfiguration Network 1 IPv4 Address: 3.3.3.3");
      Serial.println ("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.0");
      Serial.println ("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
    }
    lastState4 = state;
    delay(20);
  }
}

blh64,

Thank you, this really gets me started. I made the breadboard... literally, I took a cutting board from my wife and attached the Arduino and breadboard. Made the buttons and it works. I have added some small delays on each line. I don't know that I need to but have a feeling that I do.

I purchased an RS232 shield and waiting for it to come in the mail.

I will attempt to connect it to the VTC device on Monday. I don't think I need the shield to do that, just use the TX/RX on the board.

Thanks again. I am sure I will be back.

Seoulhawk

Okay, I am back... I had family in town and had to put this on the back burner. So I received my RS232 shield and it's working, but as I put more code in I am starting to run out of space. So I would like to know if there is a more efficient way to write the code or do I need to buy an Arduino with more memory?

const int button1 = 7;
const int button2 = 8;
const int button3 = 9;
const int button4 = 10;

int lastState1, lastState2, lastState3, lastState4;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// put your setup code here, to run once:

// wire your buttons up with one side connected to ground
// and the other side connected to the input pin

pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);

//LCD setup
lcd.begin(16, 2);
lcd.print("System Ready");

// initialize serial communication:
Serial.begin(115200);
Serial.println( "Ready" );
}

void loop() {
// put your main code here, to run repeatedly:
int state = digitalRead(button1);
if (state != lastState1 ) {
if ( state == LOW ) {
// Send to LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Setting Zero");
// Send a serial string
Serial.println("xConfiguration Network 1 IPv4 Assignment:Static");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Address: 0.0.0.0");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.255");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
delay (1000);
Serial.println ("xConfiguration H323 Gatekeeper Address: 000.000.000.000");
delay (1000);
Serial.println ("xConfiguration H323 CallSetup Mode: H323");
delay (1000);
Serial.println ("xConfiguration H323 H323Alias E164: 0000000000");
delay (1000);
Serial.println ("xConfiguration NetworkServices CDP Mode: Off");
delay (1000);
Serial.println ("xConfiguration Network 1 VLAN Voice Mode: Off");
delay (1000);
Serial.println ("xConfiguration NetworkServices H323 Mode: On");
delay (1000);
Serial.println ("xConfiguration NetworkServices SIP Mode: Off");
delay (1000);
Serial.println ("xConfiguration SystemUnit Name: nobody");
delay (1000);
Serial.println ("xCommand SystemUnit Boot [Action: Restart]");
delay (1000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Restarting");
lcd.setCursor(0, 1);
lcd.print(" system");
delay (20000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Network");
lcd.setCursor(0, 1);
lcd.print(" Zero");
}
lastState1 = state;
delay(20);
}

state = digitalRead(button2);
if (state != lastState2 ) {
if ( state == LOW ) {
// Send to LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Setting N1");
// Send a serial string
Serial.println("xConfiguration Network 1 IPv4 Assignment:Static");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Address: 0.0.0.0");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.255");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
delay (1000);
Serial.println ("xConfiguration H323 Gatekeeper Address: 000.000.000.000");
delay (1000);
Serial.println ("xConfiguration H323 CallSetup Mode: H323");
delay (1000);
Serial.println ("xConfiguration H323 H323Alias E164: 0000000000");
delay (1000);
Serial.println ("xConfiguration NetworkServices CDP Mode: Off");
delay (1000);
Serial.println ("xConfiguration Network 1 VLAN Voice Mode: Off");
delay (1000);
Serial.println ("xConfiguration NetworkServices H323 Mode: On");
delay (1000);
Serial.println ("xConfiguration NetworkServices SIP Mode: Off");
delay (1000);
Serial.println ("xConfiguration SystemUnit Name: N1");
delay (1000);
Serial.println ("xCommand SystemUnit Boot [Action: Restart]");
delay (1000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Restarting");
lcd.setCursor(0, 1);
lcd.print(" system");
delay (20000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Network");
lcd.setCursor(0, 1);
lcd.print(" ONE");
}
lastState2 = state;
delay(20);
}

state = digitalRead(button3);
if (state != lastState3 ) {
if ( state == LOW ) {
// Send to LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Setting N2");
// Send a serial string
Serial.println("xConfiguration Network 1 IPv4 Assignment:Static");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Address: 0.0.0.0");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.255");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
delay (1000);
Serial.println ("xConfiguration H323 Gatekeeper Address: 000.000.000.000");
delay (1000);
Serial.println ("xConfiguration H323 CallSetup Mode: H323");
delay (1000);
Serial.println ("xConfiguration H323 H323Alias E164: 0000000000");
delay (1000);
Serial.println ("xConfiguration NetworkServices CDP Mode: Off");
delay (1000);
Serial.println ("xConfiguration Network 1 VLAN Voice Mode: Off");
delay (1000);
Serial.println ("xConfiguration NetworkServices H323 Mode: On");
delay (1000);
Serial.println ("xConfiguration NetworkServices SIP Mode: Off");
delay (1000);
Serial.println ("xConfiguration SystemUnit Name: N1");
delay (1000);
Serial.println ("xCommand SystemUnit Boot [Action: Restart]");
delay (1000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Restarting");
lcd.setCursor(0, 1);
lcd.print(" system");
delay (20000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Network");
lcd.setCursor(0, 1);
lcd.print(" TWO");
}
lastState3 = state;
delay(20);
}

state = digitalRead(button4);
if (state != lastState4 ) {
if ( state == LOW ) {
// Send to LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Setting N6");
// Send a serial string
Serial.println("xConfiguration Network 1 IPv4 Assignment:Static");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Address: 0.0.0.0");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 SubnetMask: 255.255.255.255");
delay (1000);
Serial.println("xConfiguration Network 1 IPv4 Gateway: 0.0.0.256");
delay (1000);
Serial.println ("xConfiguration H323 Gatekeeper Address: 000.000.000.000");
delay (1000);
Serial.println ("xConfiguration H323 CallSetup Mode: H323");
delay (1000);
Serial.println ("xConfiguration H323 H323Alias E164: 0000000000");
delay (1000);
Serial.println ("xConfiguration NetworkServices CDP Mode: Off");
delay (1000);
Serial.println ("xConfiguration Network 1 VLAN Voice Mode: Off");
delay (1000);
Serial.println ("xConfiguration NetworkServices H323 Mode: On");
delay (1000);
Serial.println ("xConfiguration NetworkServices SIP Mode: Off");
delay (1000);
Serial.println ("xConfiguration SystemUnit Name: N1");
delay (1000);
Serial.println ("xCommand SystemUnit Boot [Action: Restart]");
delay (1000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Restarting");
lcd.setCursor(0, 1);
lcd.print(" system");
delay (20000);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" Network");
lcd.setCursor(0, 1);
lcd.print(" Three");
}
lastState4 = state;
delay(20);
}
}

First, learn to use CODE TAGS!
To save memory, you can look at using theF() macro to put strings into FLASH, and you have a lot of duplicated strings which could be put into a string literal constant (also in FLASH), that will get a lot back.

I didn’t look too closely, but I suspect you could shrink the code by using a function to compress the similar blocks of code.
That code makes a lot of noise, but doesn’t actually do anything other than serial.print...
This may be a bit of work, but since you feel it’s basically working, you need to refine the whole package with better style and code optimisation.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

@Tom,

Will do, Thanks!