In this lesson, we’re going to learn about a sketch on Arduino Software (IDE) that what is the bare minimum of code you need!!!

To compile properly on Arduino Software (IDE) you must call 2 function. If you want to compile that mean these two functions MUST be called. These are:  setup() và loop()

Hardware Required

  • Arduino Uno (or Genuino Board)

Mạch

image developed using Fritzing. For more circuit examples, see the Fritzing project page

CODE

How do the setup() and loop() function run ?

Any line that starts with two slashes (//) is called a comment of the sketch and it will not be read by the compiler. So that we should use two slashes (//) for commenting your code, such as explaining, how your program functions step by step…

void setup() {
// all code in this function will only run once, after each powerup or reset of the board
}
void loop() {
  // loops consecutively after creating setup()
}

Source: Arduino.vn