Introduction to Arduino (i)

Source: Internet
Author: User

Abstract: This article focuses on what Arduino, the Arduino development environment, and the Arduino-related resources website, etc. What is Arduino?

Arduino is a convenient, flexible, and easy-to-start open source electronic prototyping platform that includes hardware (various models of Arduino boards) and software (Arduino IDE).

Arduino Simple is a single-chip microcomputer, and C51 single-chip microcomputer, the Arduino platform is based on the AVR instruction set MCU. The Arduino programming is implemented using the Arduino programming language (based on Wiring) and the Arduino development environment (based on processing).

Arduino is a software and hardware platform based on open source code, built on the open source simple I/O interface version, and has a processing/wiring development environment that uses Java-like and C languages.

This is a form found on the web.

name name
foreign name Arduino Burn Way UART serial port
drive voltage DC 5V programming language C/C + + language
Programming Software Arduino IDE founder Massimo Banzi
Master microcontroller Atmega328 Open Open source

Using Arduino development has the following advantages: Open source including development environment and circuit design, such as low-cost AVR series controller, USB powered/9VDC, a treasure to buy Arduino Uno and other board cost price at dozens of yuan, Official website price at about hundreds of yuan multi-platform development support Windows, Linux, Mac OS x and other code deployment simple ISP online burn boatloader, after the firmware can be updated via the serial port or USB to RS232 line Development difficulty low simple programming can connect a variety of electronic components, such as: infrared, ultrasonic, thermistor, photoresistors, servo motor and Many other online resources such as Geek Workshop, electronic Spark, the Arduino Chinese community, such as expansion of convenient Arduino has a lot of expansion boards, such as: GSM Shield, Ethernet Shield, Wi-Fi Shield, motor Shield, USB Host Shield and other Arduino Ides

The current version of the Arduino IDE is 1.6.7 download

The interface is as follows

The source file format for Arduino is. Ino, when the Arduino creates a file, the setup () and loop () two functions are automatically generated, and the setup () function does some initialization work, which is performed only once after the system has been power on or reset. The loop () function runs continuously after Setup ().

void Setup () {
  //Put your setup code here, to run once:
  //initialization function, Arduino only executes once

void Loop () {
  // Put your main code here, to run repeatedly:
  //main work here, Arduino will always execute this part

The Arduino code is written mainly in these two functions, after understanding the two basic functions, we can not help the bottom of the interest, the bottom is how to work? Let's find out about Arduino source main.cpp

Under the Mac OS x system, the path to the file is

In a Windows environment, the file path is
C:\Program Files (x86) \arduino\hardware\arduino\cores\arduino\main.cpp

The source code is as follows:

#include <Arduino.h>

//declared weak in Arduino.h to allow user redefinitions.
int atexit (void (*/*func*/) ()) {return 0;}

Weak Empty variant initialization function.
May is redefined by variant files.
void Initvariant () __attribute__ ((weak));
void Initvariant () {}

void Setupusb () __attribute__ ((weak));
void Setupusb () {}

int main (void)
    init ();

    Initvariant ();

#if defined (Usbcon)
    Usbdevice.attach ();

    setup ();

    for (;;) {
        loop ();
        if (Serialeventrun) Serialeventrun ();

    return 0;

Due to the underlying driver, we do not study in depth, it can be concluded that: Arduino after booting, execute init (), Initvariant () and Usbdevice.attach () and other three functions after initializing the hardware environment, executed a setup () function, then loop, execute loop () function and Serialeventrun (), Arduino calls Serialevent () when the serial port has data. The specific explanation we in the study serial port time to add.

Arduino Grammar Study Please refer to the Arduino Language Reference article: Arduino official website Arduino Chinese Community Elecspark Electronic Spark Geek Workshop Good Search Encyclopedia

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.