HI,
So the code I put up had a few things taken out from the live version (there were multiple buttons each with their own output and I had added an LCD screen to error check what it was doing live and had some different syntax for the serial print stuff but thought that might confuse the issue for you guys) so I'm not surprised it doesn't compile as it is. (Unfortunately I didn't keep my old version). I don't think the LEDs and switches are likely to be a problem, they're conventional resistor->LED->pin , same with the button switches for the inputs. I had been trying different Baud rates before I uploaded here, sorry to be confusing on that and thanks for pointing it out.
Arduino is an UNO R3 (genuine) and is there to replace the tower. The RS232 shield has a switch on it that is 'off' during upload of the program (it won't upload otherwise), then I flick it 'on', then I unplug the arduino from the PC and reset with RS232 switch 'on'. When I've tested the receive side of things this works perfectly well (in fact I don't really need to reset or unplug).
for interest, here's the full code I have at the minute, But I think the problem is unlikely to be with any of the extra bits in there as more primitive versions of the code had the same problem and the stuff I've added has been attempted workarounds.
//LCD screen stuff
#include <LCD.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int n = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
//serial port stuff
static FILE uartout = {0} ;
static int uart_putchar (char c, FILE *stream)
{
Serial.write(c) ;
return 0 ;
}
//constants used for pins
const int buttonPin1 = 2; // the number of the pushbutton pin
const int buttonPin2 = 3;
const int ledPin = 12; // the number of the LED pin
const int ledPin2 = 11;
//declare variables
int buttonState = 0;
int Frozen = 0;
int Frozen2 = 0;
void setup()
{
//LCD stuff ============================================================
lcd.begin (16,2);
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
lcd.print("Ready...");
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
//serial port stuff ============================================================
Serial.begin(57600);
pinMode(ledPin,OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(ledPin2,OUTPUT);
pinMode(buttonPin2, INPUT);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
// fill in the UART file descriptor with pointer to writer.
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
// The uart is the standard output device STDOUT.
stdout = &uartout ;
}
void loop()
{
// output any serial Rx input to tht LCD
if (Serial.available()) {
delay(100);
lcd.setCursor (0,0); // go to start of 2nd line
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
lcd.setCursor (0,0);
//lcd.setBacklight(HIGH); // Backlight on
delay(3000);
}
// take any input from buttons and output to serial Tx
// read the state of the pushbutton value:
int buttonState = digitalRead(buttonPin1);
int buttonState2 = digitalRead(buttonPin2);
//int n=0;
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
buttonState = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (buttonState == HIGH) {
// turn LED on:
if (Frozen == 0){
digitalWrite(ledPin, HIGH);
//Serial.print("cine freeze");
//printf("cine freeze");
fprintf( &uartout, "cine freeze") ;
Serial.println("");
lcd.clear();
lcd.setCursor (0,0);
lcd.print("cine freeze");
Frozen=1;
delay(500);
}
else {
digitalWrite(ledPin, LOW);
//Serial.write("cine unfreeze");
//printf("cine unfreeze");
fprintf( &uartout, "cine unfreeze") ;
Serial.println("");
lcd.clear();
lcd.setCursor (0,0);
lcd.print("cine unfreeze");
Frozen=0;
delay(500);
}
}
if (buttonState2 == HIGH) {
// turn LED on:
//Serial.write('cine dump y:\test1 1 10 2');
fprintf( &uartout, "cine dump y:\test1 1 10 2") ;
Serial.println("");
lcd.clear();
lcd.setCursor (0,0);
lcd.print("cine dump y:\test1 1 10 2");
//flashy light while saving
for (int n=0; n<20; n++){
digitalWrite(ledPin2, HIGH);
delay(80);
digitalWrite(ledPin2, LOW);
delay(80);
}
delay(500);
}
}