Good greeting, I am trying to use the help of arduino in order to transmit data from one arduino to another arduino. For me as an electrical engineer can be consider as a beginner in programming so i created my own code from zero and started by sending messages but i got stuck. After converting the message into characters and converted them into binary i am facing a problem to save them as an array of integers in order to send them using LED. I will attach the code here if any can provide any help i will be really thankful. Appreciate the time you will spend reading my message even my code.
sending_string.ino (1.17 KB)
char message1[1000];//array used to save the message as letters
That's not a message. That's a novel. A reasonable sized array is definitely in order.
I don't understand what your problem is. You have an array of chars. A char is an 8 bit variable, containing some data. Each bit is on or off (1 or 0). What more do you need?
i am facing a problem to save them as an array of integers
Why do you need to do that? Saving a bit in a 16 bit variables is pissing away a lot of resources uselessly. Not that you seem to care...
I will attach the code here
Don't do that unless the code is too large to post inline. Yours is not.
The size is not a problem i guess anyhow i want to save them as an array of integers and then read them one by one if the value is one then i will make the output pin HIGH if it's zero then i will set the output pin to be LOW or you mean if i used it and send it immediately to the pin it will flicker the LED (send as HIGH and LOW).
ahmed93cent:
The size is not a problem i guess anyhow i want to save them as an array of integers and then read them one by one if the value is one then i will make the output pin HIGH if it's zero then i will set the output pin to be LOW or you mean if i used it and send it immediately to the pin it will flicker the LED (send as HIGH and LOW).
You don't need to convert a byte/char to an integer to do that though. You can still use a byte or char to have values up to 255. An integer uses up two bytes, a char (obviously) just the one.
However, on a more practical project note, you will discover that just flashing an LED is not enough for reliable communication; you will need a carrier signal that you can then modulate.
Needless to say you are not the first person to think of doing this.
Most LED comms are carried out by infrared and you will find many modules and examples both here and on the Internet. It's no different than when using your TV remote control. In fact, many modules/kits use exactly the same components because they are so cheap. But, as an engineer, I might be teaching my grandmother to suck eggs here, in which case I will stop digging this hole!
Mr.Ralph don't you think for me as an electrical engineer it is easier and more convenient to d my carrier as a circuit without using the arduino or it's easier to use the arduino itself to generate the carrier.