Mates:
I am working with this sketch to transmit Hellschreiber mode on the radio. Can anyone help me with modifying the sketch to provide for real-time text entry via a keyboard (PS2 keyboard most likely) directly connected to the arduino instead of the canned text located at in the void loop() section at the end of the sketch?
Thanks....arniep
Please read the code you posted. Does it look the same in the IDE ?
Answer. No.
Did you read and follow the advice in this sticky before posting your code Read this before posting a programming question ... - Programming Questions - Arduino Forum ?
Answer. No.
Please post the code again using code tags to make it readable.
Closer, but still not right.
Read the sticky again and note what it says about using code tags, not 'copy for forum', which is useless.
Let's try this. I hope this is acceptable and leads to some constructive help:
int radioPin = 13 ;
typedef struct glyph {
char ch ;
word col[7] ;
} Glyph ;
Glyph glyphtab[] PROGMEM = {
{' ', {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
{'A', {0x07fc, 0x0e60, 0x0c60, 0x0e60, 0x07fc, 0x0000, 0x0000}},
{'B', {0x0c0c, 0x0ffc, 0x0ccc, 0x0ccc, 0x0738, 0x0000, 0x0000}},
{'C', {0x0ffc, 0x0c0c, 0x0c0c, 0x0c0c, 0x0c0c, 0x0000, 0x0000}},
{'D', {0x0c0c, 0x0ffc, 0x0c0c, 0x0c0c, 0x07f8, 0x0000, 0x0000}},
{'E', {0x0ffc, 0x0ccc, 0x0ccc, 0x0c0c, 0x0c0c, 0x0000, 0x0000}},
{'F', {0x0ffc, 0x0cc0, 0x0cc0, 0x0c00, 0x0c00, 0x0000, 0x0000}},
{'G', {0x0ffc, 0x0c0c, 0x0c0c, 0x0ccc, 0x0cfc, 0x0000, 0x0000}},
{'H', {0x0ffc, 0x00c0, 0x00c0, 0x00c0, 0x0ffc, 0x0000, 0x0000}},
{'I', {0x0ffc, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
{'J', {0x003c, 0x000c, 0x000c, 0x000c, 0x0ffc, 0x0000, 0x0000}},
{'K', {0x0ffc, 0x00c0, 0x00e0, 0x0330, 0x0e1c, 0x0000, 0x0000}},
{'L', {0x0ffc, 0x000c, 0x000c, 0x000c, 0x000c, 0x0000, 0x0000}},
{'M', {0x0ffc, 0x0600, 0x0300, 0x0600, 0x0ffc, 0x0000, 0x0000}},
{'N', {0x0ffc, 0x0700, 0x01c0, 0x0070, 0x0ffc, 0x0000, 0x0000}},
{'O', {0x0ffc, 0x0c0c, 0x0c0c, 0x0c0c, 0x0ffc, 0x0000, 0x0000}},
{'P', {0x0c0c, 0x0ffc, 0x0ccc, 0x0cc0, 0x0780, 0x0000, 0x0000}},
{'Q', {0x0ffc, 0x0c0c, 0x0c3c, 0x0ffc, 0x000f, 0x0000, 0x0000}},
{'R', {0x0ffc, 0x0cc0, 0x0cc0, 0x0cf0, 0x079c, 0x0000, 0x0000}},
{'S', {0x078c, 0x0ccc, 0x0ccc, 0x0ccc, 0x0c78, 0x0000, 0x0000}},
{'T', {0x0c00, 0x0c00, 0x0ffc, 0x0c00, 0x0c00, 0x0000, 0x0000}},
{'U', {0x0ff8, 0x000c, 0x000c, 0x000c, 0x0ff8, 0x0000, 0x0000}},
{'V', {0x0ffc, 0x0038, 0x00e0, 0x0380, 0x0e00, 0x0000, 0x0000}},
{'W', {0x0ff8, 0x000c, 0x00f8, 0x000c, 0x0ff8, 0x0000, 0x0000}},
{'X', {0x0e1c, 0x0330, 0x01e0, 0x0330, 0x0e1c, 0x0000, 0x0000}},
{'Y', {0x0e00, 0x0380, 0x00fc, 0x0380, 0x0e00, 0x0000, 0x0000}},
{'Z', {0x0c1c, 0x0c7c, 0x0ccc, 0x0f8c, 0x0e0c, 0x0000, 0x0000}},
{'0', {0x07f8, 0x0c0c, 0x0c0c, 0x0c0c, 0x07f8, 0x0000, 0x0000}},
{'1', {0x0300, 0x0600, 0x0ffc, 0x0000, 0x0000, 0x0000, 0x0000}},
{'2', {0x061c, 0x0c3c, 0x0ccc, 0x078c, 0x000c, 0x0000, 0x0000}},
{'3', {0x0006, 0x1806, 0x198c, 0x1f98, 0x00f0, 0x0000, 0x0000}},
{'4', {0x1fe0, 0x0060, 0x0060, 0x0ffc, 0x0060, 0x0000, 0x0000}},
{'5', {0x000c, 0x000c, 0x1f8c, 0x1998, 0x18f0, 0x0000, 0x0000}},
{'6', {0x07fc, 0x0c66, 0x18c6, 0x00c6, 0x007c, 0x0000, 0x0000}},
{'7', {0x181c, 0x1870, 0x19c0, 0x1f00, 0x1c00, 0x0000, 0x0000}},
{'8', {0x0f3c, 0x19e6, 0x18c6, 0x19e6, 0x0f3c, 0x0000, 0x0000}},
{'9', {0x0f80, 0x18c6, 0x18cc, 0x1818, 0x0ff0, 0x0000, 0x0000}},
{'*', {0x018c, 0x0198, 0x0ff0, 0x0198, 0x018c, 0x0000, 0x0000}},
{'.', {0x001c, 0x001c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
{'?', {0x1800, 0x1800, 0x19ce, 0x1f00, 0x0000, 0x0000, 0x0000}},
{'!', {0x1f9c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
{'(', {0x01e0, 0x0738, 0x1c0e, 0x0000, 0x0000, 0x0000, 0x0000}},
{')', {0x1c0e, 0x0738, 0x01e0, 0x0000, 0x0000, 0x0000, 0x0000}},
{'#', {0x0330, 0x0ffc, 0x0330, 0x0ffc, 0x0330, 0x0000, 0x0000}},
{'
, {0x078c, 0x0ccc, 0x1ffe, 0x0ccc, 0x0c78, 0x0000, 0x0000}},
{'/', {0x001c, 0x0070, 0x01c0, 0x0700, 0x1c00, 0x0000, 0x0000}},
} ;
#define NGLYPHS (sizeof(glyphtab)/sizeof(glyphtab[0]))
void
encodechar(int ch)
{
int i, x, y, fch ;
word fbits ;
/* It looks sloppy to continue searching even after you've
* found the letter you are looking for, but it makes the
* timing more deterministic, which will make tuning the
* exact timing a bit simpler.
*/
for (i=0; i<NGLYPHS; i++) {
fch = pgm_read_byte(&glyphtab[i].ch) ;
if (fch == ch) {
for (x=0; x<7; x++) {
fbits = pgm_read_word(&(glyphtab[i].col[x])) ;
for (y=0; y<14; y++) {
if (fbits & (1<<y))
digitalWrite(radioPin, HIGH) ;
else
digitalWrite(radioPin, LOW) ;
delayMicroseconds(4045L) ;
}
}
}
}
}
void
encode(char *ch)
{
while (*ch != '\0')
encodechar(*ch++) ;
}
void
setup()
{
Serial.begin(9600) ;
pinMode(radioPin, OUTPUT) ;
}
void
loop()
{
encode("K6HX QTH CM87UX TMP 72F PWR 500 MICROWATTS ") ;
}
I hope this is acceptable
It is posted correctly. That is acceptable.
and leads to some constructive help:
What help do you need? The Arduino doesn't have a keyboard. At least, none of mine do.
If you are going to attach a keyboard, you'll likely see that there isn't a place to plug one in. There is a USB port, but the Arduino is a slave, and so is the keyboard. Two slaves will do nothing but sit around a drink beer until a master (or host) comes along and tells them what to do.
If you are going to use external hardware, and not tell us about it, we can hardly provide constructive help, can we?
Ukhelli:
Once again, thank you so very much for your helpful reply. I did happen to notice that, at least my, arduino does not seem to come with a keyboard. Thank you for pointing that out nevertheless. In case you missed it in my first post, this is what I was requesting assistance to do:
"Mates:
I am working with this sketch to transmit Hellschreiber mode on the radio. Can anyone help me with modifying the sketch to provide for real-time text entry via a keyboard (PS2 keyboard most likely) directly connected to the arduino instead of the canned text located at in the void loop() section at the end of the sketch?"
I am referring to the only line of code in the void loop() section, and that starts with 'encode" and then follows with the text in parentheses. Instead of that text being hard-coded, I would like to be able to instead enter text with a keyboard in real time.
Please let me know if you or anyone else does not comprehend this request for HELP. As always, I look forward to help, if anyone will do so.
Most graciously..arniep
The PS2 keyboard is not common these days but if you happen to have one, it's particularly convenient to use with an Arduino and Google should show you numerous projects demonstrating how to get keyboard input. There are even PS2 keyboard interface libraries to simplify things for you.
Mark VandeWettering has done some work on that:
http://brainwagon.org/2012/01/11/hellduino-sending-hellschreiber-from-an-arduino/
Thanks. I did start with that and, in fact, his sketch is what I have posted above. However, I am looking for help in modifying it for 'live' input from a keyboard instead of the canned message in the void loop().
Any ideas on how to do that?
Thanks...arniep
This shows how to interface a PS2 keyboard to the Arduino. From this, you should be able to process the characters as you wish.
Thanks Econojack. I had found that ps2keyboard sketch also. I just lack the knowledge of how to combine that sketch with the one I got from the example of Mark vandeWettering with the Hellschreiber encoding. Can you point the way for me?
Thanks again....arniep
If you go to that library (PS2Keyboard Library, Connect a keyboard for user input) and download the library file and unzip it. Iit contains an example, simple_test, that pretty much shows you exactly how to use the library. Just load that example, add some Serial.print()'s to it, and you'll see how to interface the keyboard.