setup()

Description

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup() function will only run once, after each powerup or reset of the Arduino board.

Example Code

int buttonPin = 3; void setup() { // put your setup code here, to executed once: Serial.begin(9600); pinMode(buttonPin, INPUT); Serial.println("This is setup code"); } void loop() { // ... }

The output on Serial Monitor:

COM6
Send
This is setup code
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

See Also

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.

※ OUR MESSAGES