admin 管理员组

文章数量: 1086019


2024年4月27日发(作者:java简述什么是变量的作用域)

Arduino Uno

目录

1 简介

2 概要

3 电路图和PCB

4 电源

5 存储器

6 输入输出

7 通信接口

8 下载程序

9 物理特征

• •

10 注意要点

11 扩展阅读

简介

Arduino UNO是Arduino USB接口系列的最新版本,作为Arduino平台的参考标

准模板。UNO的处理器核心是ATmega328,同时具有14路数字输入/输出口(其

中6路可作为PWM输出),6路模拟输入,一个16MHz晶体振荡器,一个USB口,

一个电源插座,一个ICSP header和一个复位按钮。UNO已经发布到第三版,与

前两版相比有以下新的特点:

在AREF处增加了两个管脚SDA和SCL,支持I2C接口;增加IOREF和一

个预留管脚,将来扩展板将能兼容5V和3.3V核心板。

改进了复位电路设计

USB接口芯片由ATmega16U2替代了ATmega8U2

();

pinMode(n, OUTPUT)

再:

digitalWrite(n, LOW);

data_R = er(data_S);

digitalWrite(n, HIGH);

n可以是任何口线

SS不会对其它 SPI 的设备产生大影响

另一个处理的方法,就是与 SS 相连的设备不接,也可以释放SPI总线。

概要

处理器 ATmega328

工作电压 5V

输入电压(推荐) 7-12V

输入电压(范围) 6-20V

数字IO脚 14 (其中6路作为PWM输出)

模拟输入脚 6

IO脚直流电流 40 mA

3.3V脚直流电流 50 mA

Flash Memory 32 KB (ATmega328,其中0.5 KB 用于 bootloader)

SRAM 2 KB (ATmega328)

EEPROM 1 KB (ATmega328)

工作时钟 16 MHz

电路图和PCB

所有的参考设计是基于Atmega8,168,or 328,他们的管脚是兼容的

电路图

/en/uploads/Main/Arduino_Uno_

f

硬件设计文件(Eagle文件)

/en/uploads/Main/arduino_Uno_

电源

Arduino UNO可以通过3种方式供电,而且能自动选择供电方式

外部直流电源通过电源插座供电。

电池连接电源连接器的GND和VIN引脚。

USB接口直接供电。

电源引脚说明

VIN --- 当外部直流电源接入电源插座时,可以通过VIN向外部供电;也

可以通过此引脚向UNO直接供电;VIN有电时将忽略从USB或者其他引脚

接入的电源。

5V --- 通过稳压器或USB的5V电压,为UNO上的5V芯片供电。

3.3V --- 通过稳压器产生的3.3V电压,最大驱动电流50mA。

GND --- 地脚。

存储器

ATmega328包括了片上32KB Flash,其中0.5KB用于Bootloader。同时还有2KB

SRAM和1KB EEPROM。

输入输出

1. 14路数字输入输出口:工作电压为5V,每一路能输出和接入最大电流为

40mA。每一路配置了20-50K欧姆内部上拉电阻(默认不连接)。除此之外,

有些引脚有特定的功能

o

串口信号RX(0号)、TX(1号): 与内部 ATmega8U2 USB-to-TTL

芯片相连,提供TTL电压水平的串口接收信号。

外部中断(2号和3号):触发中断引脚,可设成上升沿、下降沿或同时触发。

(

attachInterrupt()

Description

Specifies a function to call when an external interrupt occurs. Replaces any previous

function that was attached to the interrupt. Most Arduino boards have two external

interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3). The table below

shows the available interrupt pins on various boards.

Board

Uno, Ethernet

Mega2560

Leonardo

Due

int.0

2

2

3

int.1

3

3

2

int.2

int.3

int.4

int.5

21

0

20

1

19

18

(see below)

The Arduino Due board has powerful interrupt capabilities that allows you to attach

an interrupt function on all available pins. You can directly specify the pin number in

attachInterrupt().

Syntax

attachInterrupt(interrupt, function, mode)

attachInterrupt(pin, function, mode) (Arduino

Due

only)

Parameters

interrupt:

pin:

the number of the interrupt (int)

the pin number (Arduino

Due

only)

function: the function to call when the

interrupt occurs; this function

must take no parameters and

return nothing. This function is

sometimes referred to as an

interrupt service routine.

mode: defines when the interrupt should

be triggered. Four contstants are

predefined as valid values:

LOW to trigger the

interrupt whenever the pin is low,

CHANGE to trigger the

interrupt whenever the pin

changes value

RISING to trigger when

the pin goes from low to high,

FALLING for when the

pin goes from high to low.

The Due board allows also:

HIGH to trigger the

interrupt whenever the pin is

high.

(Arduino

Due

only)

Returns

none

Note

Inside the attached function, delay() won't work and the value returned by millis()

will not increment. Serial data received while in the function may be lost. You

should declare as volatile any variables that you modify within the attached

function.

Using Interrupts

Interrupts are useful for making things happen automatically in microcontroller

programs, and can help solve timing problems. Good tasks for using an interrupt may

include reading a rotary encoder, or monitoring user input.

If you wanted to insure that a program always caught the pulses from a rotary

encoder, so that it never misses a pulse, it would make it very tricky to write a

program to do anything else, because the program would need to constantly poll the

sensor lines for the encoder, in order to catch pulses when they occurred. Other

sensors have a similar interface dynamic too, such as trying to read a sound sensor

that is trying to catch a click, or an infrared slot sensor (photo-interrupter) trying to

catch a coin drop. In all of these situations, using an interrupt can free the

microcontroller to get some other work done while not missing the input.

Example

int pin = 13;

volatile int state = LOW;

void setup()

{

pinMode(pin, OUTPUT);

attachInterrupt(0, blink, CHANGE);

}

void loop()

{

digitalWrite(pin, state);

}

void blink()

{

state = !state;

}

detachInterrupt()

Description

Turns off the given interrupt.

Syntax

detachInterrupt(interrupt)

detachInterrupt(pin)

脉冲宽度调制PWM(3、5、6、9、10 、11):提供6路8位PWM

输出。

o

SPI(10(SS),11(MOSI),12(MISO),13(SCK)):SPI通信接口。

o

LED(13号):Arduino专门用于测试LED的保留接口,输出为高

时点亮LED,反之输出为低时LED熄灭。

2. 6路模拟输入A0到A5:每一路具有10位的分辨率(即输入有1024个不

同值),默认输入信号范围为0到5V,可以通过AREF调整输入上限。除

此之外,有些引脚有特定功能

o

TWI接口(SDA A4和SCL A5):支持通信接口(兼容I2C总线)。

3. AREF:模拟输入信号的参考电压。

4. Reset:信号为低时复位单片机芯片。

o

通信接口

1. 串口:ATmega328内置的UART可以通过数字口0(RX)和1(TX)与外部

实现串口通信;ATmega16U2可以访问数字口实现USB上的虚拟串口。

2. TWI(兼容I2C)接口:A4(SDA),A5(SCL)

3. SPI 接口:(10(SS),11(MOSI),12(MISO),13(SCK))

下载程序

Arduino UNO上的ATmega328已经预置了bootloader程序,因此可以通

过Arduino软件直接下载程序到UNO中,参见[[]]。

可以直接通过UNO上ICSP header直接下载程序到ATmega328,参见[[]]。

ATmega16U2的Firmware(固件)也可以通过DFU工具升级,参见[[]]。

物理特征

Arduino UNO的最大尺寸为2.7 x 2.1 inches。

注意要点

Arduino UNO上USB口附近有一个可重置的保险丝,对电路起到保护作用。

当电流超过500mA是会断开USB连接。

Arduino UNO提供了自动复位设计,可以通过主机复位。这样通过Arduino

软件下在程序到UNO中软件可以自动复位,不需要在复位按钮。在印制板

上丝印"RESET EN"处可以使能和禁止该功能。


本文标签: 输入 复位 电压 接口 引脚