/*
BlinkSOS
Turns on-board LED off and on to simulate an SOS signal
Developed on Giga R1 board sold by Arduino
Note that this reverses the pin high and low status (used in original Blink) to work correctly
I'm focused on the built-in LED (on the Giga R1) and how to turn it on and off.
The original Blink comments that: high is on (LED on) and low is off (LED off), which sounds reasonable using English.
(Added this after reading comment suggestion, thank you.)
My example code is in the public domain.
Based on Arduino supplied example Blink authored or modified by:
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
https://docs.arduino.cc/built-in-examples/basics/Blink/
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// play with these values
int shortOnDuration = 300;
int longOnDuration = 1000;
//
int shortOffDuration = 300;
int longOffDuration = 1000;
//
int blinkSeparationDelay = 1000;
int mesgSeparationDelay = 2000;
// high and low seem to be reversed, enum HIGH means off, and enum LOW means on
int ledOn = (int)LOW; // was HIGH;
int ledOff = (int)HIGH; // was LOW;
#define TURN_LED_ON digitalWrite(LED_BUILTIN, (PinStatus)ledOn)
#define TURN_LED_OFF digitalWrite(LED_BUILTIN, (PinStatus)ledOff)
// the loop function runs over and over again forever
void loop() {
// double check that it is off
//TURN_LED_OFF;
for ( int iSignal = 0; iSignal < 3; iSignal++ ) {
int curOnDuration = (iSignal == 0 || iSignal == 2) ? shortOnDuration : longOnDuration;
int curOffDuration = (iSignal == 0 || iSignal == 2) ? shortOffDuration : longOffDuration;
for ( int iBlinkIter = 0; iBlinkIter < 3; iBlinkIter++ ) {
TURN_LED_ON;
delay(curOnDuration); // wait
TURN_LED_OFF;
delay(curOffDuration); // wait
}
// double check that it is off
//TURN_LED_OFF;
// time between each three blink send
delay(blinkSeparationDelay); // wait
}
// time between 9 blink total SOS sends
delay(mesgSeparationDelay); // wait
}
Simple question:
Why do this without even explaining in the comments that the LED must be wired from pin output to cathode, anode to resistor to 5V, not the usual (for beginners) output to anode, cathode to resistor to GND?
I'm focused on the built-in LED (on the Giga R1) and how to turn it on and off. The original Blink comments that: high is on (LED on) and low is off (LED off), which sounds reasonable using English. The built-in does not work that way and I only figured this out after trying to guess why my SOS was not counting to three dots or dashes, but only blinked for the first two as part of the SOS. I understand the underlying circuit of the LED but I really wanted to save others from frustration with the example. You are correct, of course, the LED must be driven either high or low based on the design.
That nugget of context might be best added to your first post, as it’s essential. Thanks, I’ll stand down now.
I will add that, thank you.
Hi @dnharris !
You could have found the relevant information here:
https://docs.arduino.cc/tutorials/giga-r1-wifi/cheat-sheet/

But I admit that it's more satisfying and better for remembering(!) to find a solution by yourself!
Have fun with Arduino!
ec2021
BTW: This information might be of use for you also:
as the built-in LED actually consists of three leds (R,G and B) that provides further capabilities!
Thanks, will check it out.
Great!
I generally suspect not to be the first person where a certain problem occurs ... In most cases I have found at least a hint or even a solution in the Ardunio forum or some other places in the web.
So welcome to this great forum and congratulations for using the code tags in your very first post here! That's not the usual case ![]()
Good luck!
ec2021
Now I have to rewrite it using all three. jk
I did trace the defines and saw the default was green with red and blue also listed. Next, I will need an RGB define table imported from my VS stuff.
Model railways were once what microcontrollers are today… But model railway enthusiasts eventually reached their limits: available space.
With microcontrollers, time (sometimes even a human lifespan) is the limiting factor.
I gravitate to, and enjoy, the control side of model railroading. Nothing I did yet is installed or operational but I started to rewrite (a core) DCC (in Visual Studio) as a way to learn it. I have both analog and digital engines, mostly N. Instead of writing clever task looping with complicated interrupts, the Arduino is so inexpensive that maybe single purposed boards is the way to go. Automobile makers seem to do it this way, too. I've written image servers for medical purposes with security, many connections, and multithreading on Wintel and keep asking myself how I might have done it better, although it worked well. Arduino distributes all this and allows a more comfortable focus. Does it end with me or do I have to design a layout that can revert to wider maintenance someday? (rhetorical) The answer is both.