Go Down

Topic: morse code flasher - lookup table question (Read 3566 times) previous topic - next topic

Krupski


Thanks Krupski!  That's definitely what I had in mind, though I was going to use binary (0s for dits, 1s for dahs) for the pattern.

Can you explain why you're subtracting 'A' from each character?  I don't quite understand that.



Sure. If the letter "A" comes in, it's ASCII value is 65 decimal. To convert it to a zero based index, you subtract 65 from it (i.e. 'A').

So:
A=65-65 = 0
B=66-65 = 1
C=67-65 = 2
...etc..

see?
Gentlemen may prefer Blondes, but Real Men prefer Redheads!


AlphaTango

JavaMan, In looking back over the posts, I realize that I overlooked your post.  What you have written is VERY similar to what I had in mind when I wrote the pseudocode, with the exception of your case statement.  I visualized using a lookup_table (array).

Very nice!  Very clean code!

Thanks!

JavaMan

Quote
JavaMan, In looking back over the posts, I realize that I overlooked your post.  What you have written is VERY similar to what I had in mind when I wrote the pseudocode, with the exception of your case statement.  I visualized using a lookup_table (array).

Very nice!  Very clean code!

Thanks!


AlphaTango,

Thanks for the kind words. I used the case statement instead of an array because it seemed like a more intuitive way to add additional characters. By the way, the comment regarding frequency adjustment is an artifact of another version that beeps instead of flashes.

Tom

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy