Can someone take a look at this... I need a little help here: I'm Trying to send "Hello world" message using ASCII in such a way that the LED blinks with respect the binary values of "Hello world"...
How do I go about it?
Let's start with the basics. How exactly do you plan to "blink with respect" the value of an ASCII character? LED is on for a 1 and off for a 0? Or something else? Is anyone supposed to be able to read it? Wouldn't it be easier to use Morse code?
How far have you got with your program? Post it here so we can help.
Steve
Thanks, Steve for the response...
The LED should be on for a 1 and off for a 0. I want the "Hello world" message to be translated to Hexadecimal in ASCII and further to binary as "48656C6C6F20776F726C64" and "0100100001100101011011000110110001101111001000000111011101101111011100100110110001100100" respectively. The pc on the receiver side should be able to receive the message.
I think I need a little bit of introduction to the "Morse code"
Below is the TX Code:
int LEDPin = 13;
int LEDOnTime = 400;
int LEDOffTime = 500;
int numLEDBlinks = 5;
String Message = "The LED is Blinking";
void setup() {
Serial.begin(9600);
String wm1 = "Welcome to ";
String wm2 = "My Program";
String wm3;
wm3=wm1+wm2;
Serial.println(wm3);
pinMode(LEDPin, OUTPUT);
}
void loop() {
Serial.println(Message);
for (int i=1; i<=numLEDBlinks; i=i+1){
Serial.print(" You are on Blink #: ");
Serial.println(i);
digitalWrite(LEDPin,HIGH);
delay(LEDOnTime);
digitalWrite(LEDPin,LOW);
delay(LEDOffTime);
}
Serial.println(" ");
}
Find attached the ASCII table.
Regards,
Albert
Please edit your post above and fix the incorrect way you posted the code. The forum sticky post will tell you how.
You won't need the above table, Arduino uses ASCII codes anyway.
I think I need a little bit of introduction to the "Morse code"
Seriously? You never heard of Morse code? Just Google for it.
Albert94:
The LED should be on for a 1 and off for a 0.
So part of your message is 1111001000000 in binary. What exactly does that look like on the LED? I can't see anything in your code that's doing anything with individual bits in a message.
Albert94:
The pc on the receiver side should be able to receive the message.
What program in the PC is receiving the message and what is it doing with it? Which part of that code is sending "Hello world" to the PC? Or do you intend that all of the text sent using Serial will flash the LED according to it's binary representation?
Steve
PaulRB:
Please edit your post above and fix the incorrect way you posted the code. The forum sticky post will tell you how.Thanks, PaulRB. I've made the correction. The code should be in this format rather:
//Below is the TX Code:
int LEDPin = 13;
int LEDOnTime = 400;
int LEDOffTime = 500;
int numLEDBlinks = 5;
String Message = "The LED is Blinking";
void setup() {
Serial.begin(9600);
String wm1 = "Welcome to ";
String wm2 = "My Program";
String wm3;
wm3=wm1+wm2;
Serial.println(wm3);
pinMode(LEDPin, OUTPUT);
}
void loop() {
Serial.println(Message);
for (int i=1; i<=numLEDBlinks; i=i+1){
Serial.print(" You are on Blink #: ");
Serial.println(i);
digitalWrite(LEDPin,HIGH);
delay(LEDOnTime);
digitalWrite(LEDPin,LOW);
delay(LEDOffTime);
}
Serial.println(" ");
}
 You won't need the above table, Arduino uses ASCII codes anyway. Seriously? You never heard of Morse code? Just Google for it. Okay, will do a research on that Albert
slipstick:
I can't see anything in your code that's doing anything with individual bits in a message.
I would be very glad if you could help me fix that part
slipstick:
What program in the PC is receiving the message and what is it doing with it?
I am actually using two different pcs, one of the pcs is connected to an Arduino nano board and the nano board is connected to the TX circuit. The other pc is connected to an Arduino uno board and the uno board is connected to the RX circuit.
I'm using Arduino software on both pcs.
slipstick:
Or do you intend that all of the text sent using Serial will flash the LED according to it's binary representation?
Actually, that's how I was thinking the LED will work out, but don't know if that's how it's going to work out.
slipstick:
Which part of that code is sending "Hello world" to the PC?
I just rectified the code:
//Below is the TX Code:
int LEDPin = 13;
int LEDOnTime = 400;
int LEDOffTime = 500;
int nummsgBlinks = 5;
String Message = "Hello world";
void setup() {
Serial.begin(9600);
String wm1 = "Welcome to ";
String wm2 = "My Program";
String wm3;
wm3=wm1+wm2;
Serial.println(wm3);
pinMode(LEDPin, OUTPUT);
}
void loop() {
for (int i=1; i<=nummsgBlinks; i=i+1){
Serial.print(i);
Serial.print(": ");
Serial.println(Message);
digitalWrite(LEDPin,HIGH);
delay(LEDOnTime);
digitalWrite(LEDPin,LOW);
delay(LEDOffTime);
}
Serial.println(" ");
}
Warm regards,
Albert
Albert94:
PaulRB:
Please edit your post above and fix the incorrect way you posted the code. The forum sticky post will tell you how.Thanks, PaulRB. I've made the correction.
Liar! Look at your post #3, it's exactly the same as before.
Albert94:
I would be very glad if you could help me fix that part
Sorry but I can't help to fix something that doesn't exist. The "code" you've posted doesn't do anything like what you say you want. From what I can see it sends a message 5 times, flashing an LED once each time it sends the message. You either have to put a bit more effort to write something that's at least closer to your requirements or ask some more specific questions about things you don't understand.
Round here we help with fixing programs you're trying to write. We don't just write them for you.
Albert94:
I am actually using two different pcs, one of the pcs is connected to an Arduino nano board and the nano board is connected to the TX circuit. The other pc is connected to an Arduino uno board and the uno board is connected to the RX circuit.
I'm using Arduino software on both pcs.
That doesn't make any sense. The RX circuit or the TX circuit of what? It sounds like you have one Arduino sending something to a PC and a completely different PC sending something to a different Arduino. And you've only shown us one Arduino sketch. What is the other one doing?
Sorry but trying to write programs where the specification is "I was thinking it might work out that way but it might not" is hopeless. If you can't even decide what a program should do then you have no hope of being able to write a program to do it.
I suggest for now you spend some time testing your existing program. Work out exactly what it is doing and understand how it does it. Then think of some small change you might make that would get it nearer to your end goal. We can help with that and perhaps you can slowly get to where you want to be.
Steve
Sorry, I didn't specify. It's a Li-Fi TX circuit and a Li-Fi RX circuit.
@Steve
PaulRB:
Liar! Look at your post #3, it's exactly the same as before.
I'm very sorry if I offended you, I was trying to send this code instead:
//Below is the TX Code:
int LEDPin = 13;
int LEDOnTime = 400;
int LEDOffTime = 500;
int nummsgBlinks = 5;
String Message = "Hello world";
void setup() {
Serial.begin(9600);
String wm1 = "Welcome to ";
String wm2 = "My Program";
String wm3;
wm3=wm1+wm2;
Serial.println(wm3);
pinMode(LEDPin, OUTPUT);
}
void loop() {
for (int i=1; i<=nummsgBlinks; i=i+1){
Serial.print(i);
Serial.print(": ");
Serial.println(Message);
digitalWrite(LEDPin,HIGH);
delay(LEDOnTime);
digitalWrite(LEDPin,LOW);
delay(LEDOffTime);
}
Serial.println(" ");
}
Can you kindly take a look at it?
Albert
Albert94:
I'm very sorry if I offended you
I will no longer be offended, and you will have nothing to be sorry for, after you have fixed post #2.
Albert94:
Can you kindly take a look at it?
I looked at it and I agree with Steve (slipstick). Your code does not attempt to send any message by flashing the led. It simply flashes the led 5 times. There is no message contained within the flashing. Try to write some code to flash the led in a way which sends your message. If you get stuck, post your best attempt and we will try to help.
My suggestion would be to use the SoftSerial library to send your message to the Arduino pin that your tx circuit is connected to. Same for the receiving Arduino.
So let me get this right. You are trying to implement your own li-fi system transmitting between a couple of Arduinos which in turn communicate with PCs. But you didn't think it was worth mentioning that this is what you are doing?
Good luck with that. It's way too complicated for me.
Steve