Serial.read and Serial.write i have a little problem

Hey guys i am have some problems here..

In android studio i write this..

driver.setBaudRate(9600);
byte buffer[] = new byte[16];
driver.write(buffer,1000);

What should i write here in Arduino ?

incommingByte = Serial.read();
if(incommingByte == ......... )
digitalWrite(led, HIGH);

I do not know how to make a connection between this two..
I mean i want to send from android some data and arduino to interpret that data..

Ok this code is working..

Arduino

incomingByte = Serial.read();
if(Serial.peek() != -1){
digitalWrite(ledPin4,HIGH);
delay(1000);

But help me understand how bytes work..
I want to make something like..
if the phone sends "1" arduino turn led1 on
if sends "0" (the phone), arduino opens led2
and so on..

Why not check (Serial.available()) before reading?

I am new i don't know what should i do..
I think peek and available are the same ?
Any way, how can i differenciate the signals sent? And what should android app send..

Android could send single characters, same as received from Serial Monitor, then processing is simple, and any non-characters can be ignored:

if (Serial.available()>0){
incomingByte = Serial.read();
switchCase (incomingByte){
case '0':
// code
break;
case '1':
// code
break;
case '2':
// code
break;
case '3':
// code
break;
case '4':
// code
break;
case '5':
// code
break;
case '6':
// code
break;
case '7':
// code
break;
case '8':
// code
break;
case '9':
// code
break;
case 'a':
// code
break;
case 'b':
// code
break;
:
:
case 'y':
// code
break;
case 'z':
// code
break;
case 'A':
// code
break;
case 'B':
// code
break;
:
:
case 'Y':
// code
break;
case 'Z':
// code
break;
} // end switch
} // end serial avail check

Look at the examples in serial input basics. One of them probably does what you want.

...R

I think peek and available are the same ?

Why would they be the same?
Why not look at the reference?

AWOL:
Why would they be the same?
Why not look at the reference?

Ok that made me understand something..

Thank you guys, you showed me another way, but i want to ask you how can i send a specified byte

i mean byte hello ="something" An example of "something" ?

Check the link in Robin2's post. It's a very good tute.

--Michael

byte hello ="something"

In what universe can you store 10 characters in ONE byte?

Very simple serial test code:

// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT); 
  Serial.println("serial on/off test 0021"); // so I can keep track
}

void loop() {

  while (Serial.available()) {
    delay(3);  
    char c = Serial.read();
    readString += c; 
  }

  if (readString.length() >0) {
    Serial.println(readString);

    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
      Serial.println("LED ON");
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
      Serial.println("LED OFF");
    }
    readString="";
  } 
}