Programming help

/* ------------------------------------------------

  • Flash + Arduino LED Tester
  • by Jonah Model jmodel@parsaons.edu
  • modified from ARDUINO CONVERSATION, by beltran berrocal, b@progetto25zero1.com
  • ------------------------------------------------ */
    int activeLED ; // What LED has Flash requested we turn on? Numbers 2-9, for a total of 8 possible LEDs
    int switchState = 0; // What is the current switch state?
    int lastSwitchState = 0; // Was the switch previously on, or off?
    int switchPin = 13; // Which digital i/o pin is setup for the switch?

//----------------------------------------------------------
void setup() {
Serial.begin(19200); //setup serial conversation at 19200 bauds
pinMode(switchPin, INPUT); // sets the switch pin as input
for (int i=2; i<=9; i++) {
pinMode(i, OUTPUT); // sets the digital pins 2-9 as output
}
}

void loop () {

//------------------------------------------------------------------------ SWITCH LOGIC
// get the current state of the switch from our board
switchState = digitalRead(switchPin);
// if the switch has changed states, then let Flash know about it
if (switchState != lastSwitchState) {
if (switchState == 1){
sendStringToFlash(“switchOff”);
}
else if (switchState == 0){
sendStringToFlash(“switchOn”);
}
}
// now store the state for later comparison
lastSwitchState = switchState;

//------------------------------------------------------------------------ LED LOGIC

// checks if a serial message has arrived to the board
if(Serial.available() > 0) {
//must be a request to light up an LED
//activeLED should be a number 2-9, but in binary it will come in as 50-57
activeLED = Serial.read();
}

if(activeLED >= 50 && activeLED <= 57) {
//a valid LED signal has been received from Flash
// convert the byte to an int - getting ready for digitalWrite()
int outputPort = activeLED-48;

Serial.print(“Requesting LED port:”);
Serial.println(outputPort);

if(outputPort >= 2 && outputPort <= 9) {
// turns all the LEDs OFF
for (int i=2; i<=10; i++) {
digitalWrite(i,LOW);
}
// then turns your selected LED ON
digitalWrite(outputPort, HIGH);
}

// when we’re done, default the activeLED to nothing
activeLED = 0;
}
else if (activeLED) {
Serial.print(“Requesting invalid LED port:”);
Serial.println(activeLED,BYTE);
}

delay(50);

}

void sendStringToFlash (char *s) {
while (*s) {
printByte(*s++);
}
printByte(0); //notify the XMLSocket that the comunication is over
}

hi. i’m new to arduino.
while i’m compiling the program above, i keep getting this message: In function ‘void sendStringToFlash(char*)’:
error: ‘printByte’ was not declared in this scopeCouldn’t determine program size: hardware/tools/avr/bin/avr-size: ‘/tmp/build61187.tmp/ledTester.hex’: No such file

Change printByte to Serial.print :)

You are using printByte before you have declared it.

I actually think this is not OPs fault. :) http://www.arduino.cc/en/Reference/PrintByte

Just some legacy code lurking.

There is a LOT of that on the playground. I've come across many examples myself.

thanks for your help.

the program can be uploaded to arduino after i change to serial.print.

i manage to run Jonah Model's LEDTester with flash suscesfully but unfortunately, when i restart my mac n arduino, flash n arduino had totally stopped communicating. meaning i cant switch on the LED through flash.