HI EVERYONE,
i need some help in a project (i'm working on arduino uno r3 and macosx).
In the code that follows, which is used to send morse messages (see sendmsg function), i would like to take analogue readings of some pins and make the program transmit the value of these integer variables.
The function sendmsg() should be used to send a string which corresponds to an analog reading of a sensor.
however this sendmsg() function accepts text in the form of "text", but i can't make it accept strings which correspond to analogue reading values.
thanks and 73
THE CODE FOLLOWS::::
struct t_mtab { char c, pat; } ;
struct t_mtab morsetab[] = {
{'.', 106},
{',', 115},
{'?', 76},
{'/', 41},
{'A', 6},
{'B', 17},
{'C', 21},
{'D', 9},
{'E', 2},
{'F', 20},
{'G', 11},
{'H', 16},
{'I', 4},
{'J', 30},
{'K', 13},
{'L', 18},
{'M', 7},
{'N', 5},
{'O', 15},
{'P', 22},
{'Q', 27},
{'R', 10},
{'S', 8},
{'T', 3},
{'U', 12},
{'V', 24},
{'W', 14},
{'X', 25},
{'Y', 29},
{'Z', 19},
{'1', 62},
{'2', 60},
{'3', 56},
{'4', 48},
{'5', 32},
{'6', 33},
{'7', 35},
{'8', 39},
{'9', 47},
{'0', 63}
} ;
#define N_MORSE (sizeof(morsetab)/sizeof(morsetab[0]))
#define SPEED (14)
#define DOTLEN (1200/SPEED)
#define DASHLEN (3*(1200/SPEED))
void
dash()
{
digitalWrite(0, HIGH) ;
delay(DASHLEN);
digitalWrite(0, LOW) ;
delay(DOTLEN) ;
}
void
dit()
{
digitalWrite(0, HIGH) ;
delay(DOTLEN);
digitalWrite(0, LOW) ;
delay(DOTLEN);
}
void
send(char c)
{
int i ;
if (c == ' ') {
delay(7*DOTLEN) ;
return ;
}
for (i=0; i<N_MORSE; i++) {
if (morsetab[i].c == c) {
unsigned char p = morsetab[i].pat ;
while (p != 1) {
if (p & 1)
dash() ;
else
dit() ;
p = p / 2 ;
}
delay(2*DOTLEN) ;
return ;
}
}
}
void
sendmsg(char *str)
{
while (*str)
send(*str++) ;
}
void setup() {
pinMode(0, OUTPUT);
}
void loop() {
sendmsg("MESSAGE") ;
delay(1500) ;
}