HI
Below is my transmitter code. Can you rectifier it because when i conected a push button to pin 3 and push button is pressed, the data is not transmitting as i observed from the serial monitor(nothing pop from the serial monitor)
int crankingPin = 3;
int liftoffPin = 4;
int upwardPin = 5;
int downwardPin = 6;
int turnleftPin = 7;
int turnrightPin = 8;
int forwardPin = 9;
int backwardPin = 10;
int buttonstate;
void setup()
{
// initialize the serial communication:
Serial.begin(9600);
After some example i go through, i change Serial.write( 8 ) ; to Serial.write('8') ; and the serial monitor showing integer 8 when i pressed the push button. So am i transferring data ?
After some example i go through, i change Serial.write( 8 ) ; to Serial.write('8') ; and the serial monitor showing integer 8 when i pressed the push button. So am i transferring data ?
Read careful the example options avalible below in serial printing for how the data will be handled and sent to the PC.
What we are wondering is why you insist on using Serial.write to send ascii data, when that is not what is was meant to send. Why won't you change it to Serial.print()?
Hmm. Basically i need to transfer few 4 bit binary data (1000, 1001, 1011, 1101, 1110 and etc)) to another arduino and the receiving arduino will receive it. For each 4 bit binary data received , it executes a certain routines such controlling the speed of motor or brightness of led, So how can i do that?
Are you trying to transfer data to another Arduino via the Serial Monitor? You might use Serial.write() to talk to a device that understands binary data, but you use Serial.print() to talk to the Serial Monitor.
For each 4 bit binary data received , it executes a certain routines such controlling the speed of motor or brightness of led,
Serial data is one byte/8 bits long. You can not send just 4 bits. What is the significance of sending a binary value, anyway? The receiver still has to compare the received value against all possible values.
int val = Serial.read();
switch(val)
{
case 0b0000: Do0(); break;
case 0b0001: Do1(); break;
case 0b0010: Do2(); break;
case 0b0011: Do3(); break;
case 0b0400: Do4(); break;
}
will be no faster than:
int val = Serial.read();
switch(val)
{
case '0': Do0(); break;
case '1': Do1(); break;
case '2': Do2(); break;
case '3': Do3(); break;
case '4': Do4(); break;
}
The second set of values looks reasonable in the Serial Monitor, too. The first set of values does not.
The character data, since it is one byte long, transmits in the same length of time as the byte value.
yeah i m trying to send binary data to another arduino. So to check i m using serial monitor whether it able to send the binary data or not? basically the code for transmitter can be use right? the receiver code follows your idea?