# Help me to understand this code

Do I understand this code correct?

Let’s take it that the first Char is = to the first code in the lookup table. ({ 1,15, 9})

Is the first value for “_sym” in the command “analogWrite(RADIOPIN, _sym);” then 1 or is it 3

The code is
:

unsigned char varicode = {
/* Primary alphabet */
{ 1,15, 9},
};
uint8_t _sym = 0;
void loop() {
dominoex_string(“M0UPU DOMINOEX TEST\n”);

}
void dominoex_txsym(uint8_t sym)
{
_sym = (_sym + 2 + sym) % 18;
delay(64);
}
void dominoex_txchar(uint16_t vcode)
{
uint8_t i, c;

for(i = 0; i < 3; i++)
{
c = varicode[vcode];
if(i && !(c & 0x8)) break;
dominoex_txsym(c);
}
}
void dominoex_string(char *s)
{
for(; *s; s++) dominoex_txchar(*s);
}

Code tags, code tags...

It might help understanding to unroll the loop:

``````i = 0;
c = 1;
if(i && !(c & 0x8)) break;  // i==false so never break
dominoex_txsym(c);  // call with c==1

i = 1;
c = 15;
if(i && !(c & 0x8)) break;  // i==true but "!(c & 0x8))" is false so don't break
dominoex_txsym(c);  // call with c==15

i = 2;
c = 9;
if(i && !(c & 0x8)) break;  // i==true but "!(c & 0x8))" is false so don't break
dominoex_txsym(c);  // call with c==9
``````

So the first value is 3:
(0 + 2 + 1) % 18 → 3

The second is 2:
(3 + 2 + 15) % 18 → 20 % 18 → 2

The third is 13:
(2 + 2 + 9) % 18 → 13 % 18 → 13

Thanks Shannon i will try to redo this in VB For a PICAXE

zs6wbt:
Thanks Shannon i will try to redo this in VB For a PICAXE

... His last name is not "Member"...