Hello,
I have found this code interesting because when I copied it from Mr S. Monks book & observed it work I was sure that it was not what I have experiences of what an SOS code ought to be.
So I slowed down the process so that I could watch the inbuilt led flash more easily, (example one below) I also deleted one of the 200 commands as written by Mr S. Monk.)
''{200, 200, 200, 500, 500, 500, 200, 200, 200}; ''
This line of command makes the Uno that I am using flash 4 times quickly, & not the allocated command of three quick flashes that is meant to represent S at the start of the code.
Then one sees three longer flashes to represent the O.
Finally, one experiences a different rate of flashes for the supposedly S at the end of the code that is meant to represent SOS!
Has any one observed similar results whilst experimenting with this code from Mr S. Monk?
Thank you
Dafyddclaud.
–---------------------------------------------------------------------------------------
// My modified code to prove a point.
int ledPin = 13;
int durations [] = {400, 400, 1000, 1000, 1000, 400, 400, 400,};
void setup ()
{
pinMode (ledPin, OUTPUT);
}
void loop ()
{
for (int i = 0; i < 9; i++)
{
flash (durations*);*
- }*
- delay (2000);*
}
void flash(int delayPeriod)
{ - digitalWrite(ledPin, HIGH);*
- delay(delayPeriod);*
- digitalWrite(ledPin, LOW);*
- delay(delayPeriod);*
}
–----------------------------------------------------------------
// S.Monk's sketch 5 – 02 from his web site & book.
int ledPin = 13;
int durations[] = {200, 200, 200, 500, 500, 500, 200, 200, 200};
void setup()
{ - pinMode(ledPin, OUTPUT);*
}
void loop()
{ - for (int i = 0; i < 9; i++)*
- {*
_ flash(durations*);_
_ }_
_ delay(1000);_
_}_
void flash(int duration)
_{_
_ digitalWrite(ledPin, HIGH);_
_ delay(duration);_
_ digitalWrite(ledPin, LOW);_
_ delay(duration);_
_}*_