[Arduino] Basics

Official website

https://www.arduino.cc/

 

What is the Arduino bootloader?

https://www.cnblogs.com/anandexuechengzhangzhilu/p/10719808.html

On the arduino board, as the core of avr microcontroller will often burn a bootloader, the bootloader stuff is actually called the R & D team arduino arduino board for a piece of code development, by means of this code, we can burn without external tool case record down to our own code downloaded to the AVR microcontroller. To make it easier to understand some of my friends, might analogy, bootloader windows operating system similar to our computers, and our code to run various programs on windows is similar.

Generally, sellers will put arduino board bootloader each plate were burned after the sale, so buyers can directly after the board received the program I have written in arduinoIDE by means of a PC's USB port to download to arduino microcontroller Inside. Of course, downloading bootloader is required by means of an external downloader, downloader can support a lot of the more cost-effective base is usbtinyisp, many stores have sold on Taobao, such as price easyJet robot circuit is only 38 yuan .

For the average user, because occasionally there will be a breach of the bootloader download their code, like PC windows system collapsed as suddenly. At this time, you will need to use an external downloader to recover the bootloader, reinstall the system is equivalent to PC.

 

Arduino in serial.available () and serial.read () use?

https://www.cnblogs.com/anandexuechengzhangzhilu/p/10719555.html

Serial.available () refers to the number of characters in the serial buffer return current remaining. This function is generally used to determine the presence or absence of serial data in the buffer, when Serial.available ()> 0, indicating that the received serial data, can be read.

Serial.read () means is removed from the serial buffer and read the data of a Byte. To have such apparatus for transmitting data through the serial port Arduino, we can read the data will be transmitted using the Serial.read ().

A typical usage is as follows:

while (Serial.available()>0)
{
  data = Serial.read();
  delay(2);
}

The above code means that, when the serial data is received (above Serial.available ()> 0 sentence), and repeatedly reading the data assigned to the serial data (top data = Serial.read () sentence), until the data reading (i.e. Serial.available () = 0 when).

 

Detailed pin assignment FIG Arduino Uno development board and definitions

https://www.yiboard.com/thread-831-1-1.html

Arduino Uno Atmel microcontroller uses the ATmega328. FIG Arduino Uno pin assignment development board 14 comprises digital pins, 6 analog inputs, power jack, USB connector plug and ICSP.
Pins are multiplexed with different features provide additional options, such as the drive motor, LED, reading sensor and the like.

Arduino Uno Pin Assignment - Power

Arduino Uno development boards power three ways:

● DC power jack - can be used as a power jack Arduino development board power. Power jack typically connected to one adapter. Development board power range may be 5-20V, but manufacturers recommended that it held between 7-12V. Higher than 12V, voltage regulator chip may overheat, insufficient power may be lower than 7V.

● VIN pin - This pin for external power supply for the development board Arduino Uno. Voltage should be controlled within the range mentioned above.

● USB cable - connected to a computer, provides 500mA / 5V voltage.

Arduino Uno Pin Assignment - Analog input

Arduino Uno six analog pins, as they ADC (ADC) used.
These pins are used as analog inputs, but can also be used as a digital input or digital output.

Analog to digital conversion

ADC an analog to digital converter. ADC for converting an analog signal into a digital signal of the electronic circuit. This allows the digital representation of the analog signal processor (which is a digital device) measuring an analog signal and uses it in its operation.
Arduino pins A0-A5 can read analog voltages. On Arduino, ADC resolution of 10 bits, which means that it can be an analog voltage by a digital level 1,024. Voltage into the ADC bit microprocessor can be appreciated.
A common example is the ADC Voice over IP (VoIP). Each smart phone has a microphone, a sound wave (voice) can be converted to an analog voltage. This is achieved by ADC apparatus, and converted into digital data, transmitted over the Internet to a receiving end.

 

Arduino Uno pin assignments - digital pin

Arduino Uno pin 0-13 is used as a digital input / output pins.
Wherein the pin 13 is connected to the onboard LED indicators; 3,5,6,9,10,11 with PWM pin.

Note that:
● each pin may be provided / received 40 mA maximum current. It is recommended that the current is 20 mA.
● absolute maximum current for all pins to 200mA.

 

What digital level mean?

数字是一种表示1位电压的方式:0或1。
Arduino上的数字引脚是根据用户需求设计为输入或输出的引脚。数字引脚可以打开或关闭。开启时,它们处于5V的高电平状态,当关闭时,它们处于0V的低电平状态。

在Arduino上,当数字引脚配置为输出时,它们设置为0或5V。

当数字引脚配置为输入时,电压由外部设备提供。该电压可以在0-5V之间变化,并转换成数字表示(0或1)。为了确定这一点,有2个阈值:

● 低于0.8v - 视为0。
● 高于2.0v - 视为1。

将组件连接到数字引脚时,确保逻辑电平匹配。如果电压在阈值之间,则返回值将不确定。


什么是PWM?

通常,脉宽调制(PWM)是一种调制技术,用于将消息编码为脉冲信号。
PWM由两个关键部分组成:频率和占空比。
PWM频率决定了完成单个周期(周期)所需的时间以及信号从高到低的波动速度。占空比决定信号在总时间段内保持高电平的时间。占空比以百分比表示。

在Arduino中,支持PWM的引脚产生约500Hz的恒定频率,而占空比根据用户设置的参数而变化。见下图:

PWM信号用于直流电机的速度控制,调光LED等。


通信协议

串行(TTL)- 数字引脚0和1是Arduino Uno的串行引脚。
它们由板载USB模块使用。


什么是串行通信?

串行通信用于在Arduino板和其他串行设备(如计算机,显示器,传感器等)之间交换数据。
每块Arduino板至少有一个串口。串行通信发生在数字引脚0(RX)和1(TX)以及USB上。
Arduino也支持通过数字引脚与SoftwareSerial Library进行串行通信。
这允许用户连接多个支持串行的设备,并保留主串行端口可用于USB。

软件串行和硬件串行 - 大多数微控制器都具有用于与其他串行设备进行通信的硬件。软件串行端口使用引脚更改中断系统进行通信。有一个用于软件串行通信的内置库。处理器使用软件串行来模拟额外的串行端口。软件串行唯一的缺点是它需要更多的处理,并且不能支持与硬件串行相同的高速。


SPI - SS / SCK / MISO / MOSI引脚是SPI通信的专用引脚。

它们可以在Arduino Uno的数字引脚10-13和ICSP插头上找到。

串行外设接口(Serial Peripheral Interface,SPI)是一种串行数据协议,由微控制器用来与总线中的一个或多个外部设备进行通信,如连接。 SPI也可以用来连接2个微控制器。在SPI总线上,总是有一个设备表示为主设备,其余所有设备都表示为从设备。在大多数情况下,微控制器是主设备。 SS(从选择)引脚确定主器件当前正在与哪个器件通信。

启用S​​PI的器件始终具有以下引脚:
● MISO(主从输出) - 用于向主设备发送数据的线路
● MOSI(主机输出从机输入) - 发送数据到外围设备的主机线
● SCK(串行时钟) - 由主设备生成的用于同步数据传输的时钟信号。

 

I2C - SCL / SDA引脚是I2C通信的专用引脚。

在Arduino Uno上,它们可以在模拟引脚A4和A5上找到。I2C通信协议通常称为 "I2C总线"。

I2C协议旨在实现单个电路板上组件之间的通信。使用I2C时,有2条通信线,称为SCL和SDA。
● SCL是用于同步数据传输的时钟线。
● SDA是用于传输数据的通讯线。

I2C总线上的每个器件都有一个唯一的地址,最多可以在同一条总线上连接255个器件。

 

Aref - 模拟输入的参考电压

中断 - INT0和INT1

Arduino Uno有两个外部中断引脚。

外部中断 - 外部中断是外部干扰出现时发生的系统中断。

干扰可能来自用户或网络中的其他硬件设备。 Arduino中这些中断的常见用途是读取编码器产生的方波或外部事件唤醒处理器的频率。

Arduino有两种形式的中断:

● 外部输入
● 引脚状态变化

ATmega168 / 328上有两个外部中断引脚,称为INT0和INT1。 INT0和INT1分别映射到引脚2和3。相反,引脚变化中断可以在任何引脚上激活。

Arduino Uno引脚定义 - ICSP插头

ICSP表示在线串行编程。该名称源自在系统编程(ISP)。

Arduino相关的制造商,如Atmel,开发了自己的在线串行编程插头。这些引脚使用户能够编程Arduino开发板上的固件。 Arduino开发板上有6个ICSP引脚,可通过编程电缆连接到编程器设备。

 

Guess you like

Origin www.cnblogs.com/jinzesudawei/p/12117692.html