i am sending data 8 bit to my arduino and i want my data to get into the rx ( by rf module 434A receiver).
So, i tried to send data but he always gets the data as "-1" .
i did a check by shorting the rx and the tx of the arduino to where is the problem but it works ( the data from the tx of the arduino gets into the rx of the arduino pretty good)',
i also checked my transmitter and my receiver they works good too ,
anybody thinks he knows where the problem can come from?
here is my simple code:
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.write(255);
delay(100);
int x=Serial.read();
Serial.print(x);
delay(100);
thanks for the answer i did what you wrote but its cannot comiled
it write me an eror : "cannot convrert from int to cont_units"
and i tried to write the program with byte and with char and now it givs me someting like y in Gibrish so i rhort with wireseally dont know what to do ' i tried to connect other microconroller in serial( srhort with wires the tx of the microcontroller -pic18f8520 to the rx of the arduinothwy both works at ttl level 0-5 volt) and desame ;
when i am writeing :
if( serial.available())
{
}
nothings happenes, the program seems to be stucked in a loop ....
@grag38:
You're pushing towards 100 posts.
Don't you think it is about time you started posting code properly?
if (Serial.available()) {
int x =Serial.read();
Serial.print(x, HEX); // Does anyone remember ASCII codes in decimal?
Serial.print(' ');
delay(10);
} else Serial.print('.');