OK so you want detail and example code here we go...
First I am using a Samsung Galaxy Tab A with android 9 and the up to date ArduinoDroid. The Auriga is set as a MEGA 2560 or MEGA ADK. If I set MEGA CH340G ArduinoDroid simply says it does not recognise the board the other setting it does.
Compiling is fine but when I attempt to download ArduinoDroid reports 'error : cannot change the baud rate' or to be more specific
'overriding baud rate :: 115200'
'failed to set baud rate :: -9'
You wanted to see example code, here it is.
// Project 1 - LED Flasher
int ledPin = 10;
int spkr_pin=8;
int led_on_pin=7;
int spkr_on_pin=4;
boolean led_on;
boolean spkr_on;
int dot_length=7;
int dash_length=21;
int dot_dash_length=14;
int char_length=28;
int word_length=14;
int sentance_length=42;
int scale;
int potPin=2;
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_A3 220
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
int notes[]={
NOTE_C3,
NOTE_CS3,
NOTE_D3,
NOTE_DS3,
NOTE_E3,
NOTE_F3,
NOTE_FS3,
NOTE_G3,
NOTE_GS3,
NOTE_A3,
NOTE_AS3,
NOTE_B3,
NOTE_C4,
NOTE_CS4,
NOTE_D4,
NOTE_DS4,
NOTE_E4,
NOTE_F4,
NOTE_FS4,
NOTE_G4,
NOTE_GS4};
//char message[]="the quick brown fox jumps over the lazy dogs back";
char message[]="the lemon and lime are always at war. they quarrel they kick each other to the floor. "\
"lemon to the lime says you havent got much time. lime to the lemon says its armegeddon "\
"when in fact they are nothing but bores.";
int numerical_digits[10];
int alpha_digits[26];
int morse_digits[]={
0b100000,
0b110000,
0b111000,
0b111100,
0b111110,
0b111111,
0b101111,
0b100111,
0b100011,
0b100001};
int morse_alpha[]={
0b110, // a
0b10111, // b
0b10101, // c
0b1011, // d
0b11, // e
0b11101, // f
0b1001, // g
0b11111, // h
0b111, // i
0b11000, // j
0b1010, // k
0b11011, // l
0b100, // m
0b101, // n
0b1000, // o
0b11001, // p
0b10010, // q
0b1101, // r
0b1111, // s
0b10, // t
0b1110, // u
0b11110, // v
0b1100, // w
0b10110, // x
0b10100, // y
0b10011}; // z
void dot_dash(int c, int period)
{
if (c>0)
{
for (; c>0; c--)
{
if (led_on)
{
digitalWrite(ledPin, HIGH);
}
if (spkr_on)
{
tone(spkr_pin, 1000, period*scale);
}
delay(period*scale);
if (led_on)
{
digitalWrite(ledPin, LOW);
}
delay(dot_dash_length*scale);
}
}
}
void output_morse(byte m)
{
byte mask=32;
if (m!=0)
{
while ((m & mask)==0)
{
mask=mask >> 1;
}
mask=mask >> 1;
while (mask!=0)
{
if ((m & mask)!=0)
dot_dash(1,dot_length);
else
dot_dash(1,dash_length);
mask=mask >> 1;
}
delay(char_length*scale);
}
}
void show_char(char c)
{
byte b=byte(c) & 0x7f;
if ((c>='0') && (c<='9'))
{
output_morse(morse_digits[b-byte('0')]);
}
else if ((c>='A') && (c<='Z'))
{
output_morse(morse_alpha[b-byte('A')]);
}
else if ((c>='a') && (c<='z'))
{
output_morse(morse_alpha[b-byte('a')]);
}
else if (c==' ')
{
delay(word_length*scale);
}
}
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(led_on_pin, INPUT);
pinMode(spkr_pin, OUTPUT);
pinMode(spkr_on_pin, INPUT);
scale=(analogRead(potPin)+1)/64+1;
}
void loop()
{
for (int i=0, j=sizeof(message); i<j; i++)
{
led_on=digitalRead(led_on_pin)==HIGH;
spkr_on=digitalRead(spkr_on_pin)==HIGH;
scale=(analogRead(potPin)+1)/64+1;
if (message[i]=='.')
{
delay(sentance_length*scale);
}
else
{
show_char(message[i]);
}
}
delay(sentance_length*scale);
}
AndRue