Good day, I have a serial device that when connected via hyper terminal gives me a status report when I press the letter 'd' no enter key or anything required just the letter d. Also Ctrl-t will give me some routing information.
I would like to press a button connected to the arduino and send the b to the serial device and view the status information back from it.
At this point I have the Serial device connected to the arduino and am able to see messages from it, however when I press the switch connected to pin 2 the serial device does not send me the status output as expected and as seen via direct serial connection to my computer with hyperterminal.
Does anyone have an experience or input regarding this?
#include <SoftwareSerial.h>
// software serial #1: TX = digital pin 10, RX = digital pin 11
SoftwareSerial portOne(10, 11);
const int buttonPin = 2; // the number of the pushbutton pin
const int button1Pin = 4;
const int ledPin = 13; // the number of the LED pin
//define char to send to serial
char stat = 'd';
char route = '\x14';
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int button1State = 0;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(button1Pin, INPUT);
Serial.begin(4800);
while (!Serial) {; // wait for serial port to connect. Needed for native USB port only
}
// Start each software serial port
portOne.begin(4800);
while (!portOne) {; // wait for serial port to connect. Needed for native USB port only
}
}
// the loop function runs over and over again forever
void loop() {
static int Once = 0;
static int Once1 = 0;
buttonState = digitalRead(buttonPin);
button1State = digitalRead(button1Pin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH ) {
if (Once == 0) {
Once = 1;
// turn LED on so I can tell the button is working
digitalWrite(ledPin, HIGH);
// send d to Radio
portOne.write(stat);
// send d to serial monitor so I can see the charector
Serial.print(stat);
}
}
if (buttonState == LOW) {
// turn LED off:
Once = 0;
digitalWrite(ledPin, LOW);
}
// check if the other pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (button1State == HIGH) {
if (Once1 == 0) {
Once1 = 1;
// turn LED on:
// digitalWrite(ledPin, HIGH);
// send ctrl-t to radio
portOne.write(route);
}
}
if (button1State == LOW) {
// turn LED off:
//digitalWrite(ledPin, LOW);
Once1 = 0;
}
portOne.listen();
// read data from the Software Serial portOne
// and send to the hardware serial port:
while (portOne.available() > 0) {
char inByte = portOne.read();
Serial.print(inByte);
}
}

Serial.println ("Sending 'd' to device");- then you'll know if it is a switch-detection issue, or a comms issue. – Nick Gammon Mar 09 '16 at 20:05// send d to Radio(and the code appears to actually do that). Is this correct, and could that be the source of your error? – JRobert Mar 09 '16 at 20:20// send d to Radio portOne.write(stat); // send d to serial monitor so I can see the charector Serial.print(stat);– Tony M Mar 09 '16 at 20:50