Hello World!


Let’s begin our journey with a simple blinking LED program, it’s a simple Arduino sketch which could be considered as the “Hello World!” of Arduino. While simple the “Hello World!” program is very important in that it’s a way of saying “Hi there, I am all good. Let’s get down to business”.

What we will need:
  • Arduino Uno board
  • Arduino IDE installed
  • Micro USB cable
Arduino Uno Board

The Arduino IDE comes pre-loaded with a vast selection of sketches to get things moving. In our case, there is already a sketch to do exactly what we want called Blink. It can be found under the Basics Built-In Examples.

I have also updated the sketch to use millis() instead of delay() since delay() actually pauses the program which is not what I wanted to do. The final Blink sketch will look as follow:

static void SetLedState(bool state)
{
  if (state)
  {
    digitalWrite(LED_BUILTIN, HIGH);
  }
  else
  {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
}

void loop()
{
  unsigned int secondsSinceBoot = millis() / 1000;

  if (secondsSinceBoot % 2 != 0)
  {
    SetLedState(true);
  }
  else
  {
    SetLedState(false);
  }
}

After that, all that’s needed to be done is connect the USB cable, set the correct COM port and load it onto the Arduino Uno.

Categories: Arduino, Internet of things

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: