Help me about these codes

How about this:

void setup(){

int state = digitalRead(button);

if(button == HIGH){
write();
delay(10000);
reply();
}

void write(){
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
}

void reply(){
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
Serial.write((byte)0x00);
}

Hello, please follow this advice before you are punished!!

AWOL:
Code tags would be good too. I do believe you’ve been asked before to do that.

Just write:
[ code ][ /code ]
(without spaces)

And, if you explained the problem it would be useful :slight_smile:

In your code is missing a closing bracket “}”, that’s why indentation is useful :slight_smile:

So the way to enable people to help you is to explain your problem. This means saying

  1. What you want to accomplish - we are lacking this
  2. What is actually happening (and why this is wrong) - we are lacking this
  3. Show all relevant information - you seem to have done this (apart from lack of code tags).

Usually people fail on 2) and 3), not on 1)!!

you are using button when you should be using state...

apart from that, it should work as written.

Yeah, sorry about the lack of information. Sorry but I don’t have the codes right now, just brainstorming about what I want to do.

First, I want a command that will write a data to the serial and that command is the switch, if the switch send a logic high, the writing of data to the serial will be followed. Then another set of data will be followed.

Second, about the void reply, it is wrong, typographical error.

this is the real on:
byte RxData[8];
int i;

if(Serial.available()>0){
for(i=0; i<8; i++){
RxData = Serial.read();
Serial.print(RxData*, HEX);*
}
if(RxData[4] == 0x05){
* Serial.print("Hello User);}*
else{
Serial.print(“No User profile”);
}
Third, I call that data in the RxData[8], but I’m getting zero,
The problem is about the RxData*, like it doesn’t store data at all.*

if(Serial.available()>0){
 for(i=0; i<8; i++){
 RxData = Serial.read();

If there is at least one byte available to read, read all 8 of them. Nope. FAIL!

this is the real on:

Really?
Complete with italics?

Is it so hard to post stuff between tags?
How many times is it now you've been asked for this simple courtesy?

There are a few really good reasons we ask you to post properly, and you've demonstrated one of them very well.

Fine, I will follow ALL YOUR DIRECTION CORRECTLY but ANSWER ALL MY QUESTIONS CORRECTLY WITHOUT ANY TRASH TALK.
I know that I am a noob here and I am approach a master or god for help, so please be considerate.

if(Serial.available()>0){
for(i=0; i<0; i++){
RxData[i] = Serial.read();
Serial.print(RxData[i], HEX);
}
}

This only reads the data not storing it, so please kindly help me.

See reply #5

If you KNOW that you need to read 8 bytes, you must not do so until there are at least 8 bytes to read. Look at the documentation for the Serial.available() method. You will see that, despite your usage (which I abhor) that it is NOT a boolean function.

Thank you. Can you give some sites or pages about this serial.available documentations.

Up there, on the left is a button labelled “Main site”.
Go there, and click on the button labelled “Reference”.

papyrus12:
ANSWER ALL MY QUESTIONS CORRECTLY WITHOUT ANY TRASH TALK.

You are asking strangers to expend their time and attention helping you, and offering nothing in return. Do you think that the attitude you're showing here is going to encourage them to do that?

papyrus12:
Fine, I will follow ALL YOUR DIRECTION CORRECTLY but ANSWER ALL MY QUESTIONS CORRECTLY WITHOUT ANY TRASH TALK.

No, you don’t follow the directions.

http://arduino.cc/forum/index.php/topic,126907

You have been asked repeatedly to put your code into code tags, and you just ignore us. Now you are shouting insults. Stop it.