-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de09e02
Showing
62 changed files
with
14,425 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: "**/node_modules" | ||
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: ${{ runner.OS }}-npm-cache- | ||
|
||
- run: npm install | ||
- run: npm run build | ||
|
||
- name: Deploy to github pages | ||
uses: crazy-max/ghaction-github-pages@v3.1.0 | ||
with: | ||
target_branch: gh-pages | ||
build_dir: build | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# 校科协技术开发部 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
slug: first-blog-post | ||
title: First Blog Post | ||
authors: | ||
name: Cael | ||
tags: [hola, docusaurus] | ||
--- | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
endi: | ||
name: Cael | ||
title: 技术部退休成员 | ||
url: https://github.com/MR-Addict | ||
image_url: https://avatars.githubusercontent.com/u/75357598?v=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
title: Arduino和Arduino IDE | ||
--- | ||
|
||
# Arduino 和 Arduino IDE | ||
|
||
## 1. Arduino 开发板 | ||
|
||
Arduino 至今拥有非常多的开发板,其中最为流行的就是 8 位的 AVR 单片机,当然 Arduino 也有 32 位单片机,下面是几款比较流行的开发板。 | ||
|
||
AVR 开发板: | ||
|
||
| Arduino Uno | Arduino Nano | Arduino Mega | | ||
| :----------------------------: | :-----------------------------: | :------------------------------ | | ||
| ![Arduino Uno](images/1-1.png) | ![Arduino Nano](images/1-2.png) | ![Arduino Mega](images/1-3.png) | | ||
|
||
Arduino Nano 33 系列开发板: | ||
|
||
| Arduino Nano 33 IOT | Arduino Nano 33 BLE | Arduino Nano 33 BLE Sense | | ||
| :------------------------------------: | :------------------------------------: | :------------------------------------------- | | ||
| ![Arduino Nano 33 IOT](images/1-4.png) | ![Arduino Nano 33 BLE](images/1-5.png) | ![Arduino Nano 33 BLE Sense](images/1-6.png) | | ||
|
||
Arduino 还有一些工业级的开发板: | ||
|
||
| Arduino MKR Vidor 4000 | Arduino MKR NB 1500 | Arduino Portenta H7 | | ||
| :----------------------------------------: | :-------------------------------------: | :-------------------------------------: | | ||
| ![Arduino MKR Vidor 4000](images/1-11.png) | ![Arduino MKR NB 1500](images/1-12.png) | ![Arduino Portenta H7](images/1-13.png) | | ||
|
||
以及一批不再生产的退休开发板: | ||
|
||
| Arduino Lilypad | Arduino ESPLORA | Arduino YUN Shiled | | ||
| :--------------------------------: | :--------------------------------: | :------------------------------------: | | ||
| ![Arduino Lilypad](images/1-7.png) | ![Arduino ESPLORA](images/1-8.png) | ![Arduino YUN Shield](images/1-14.png) | | ||
|
||
## 2. Arduino Uno | ||
|
||
Arduino Uno 可以说是 Arduino 开发板家族中最为流行的一款,可以说是每个 Arduino 初学者都会拥有的一款开发板,我们就以 Uno 板为例对 AVR 芯片硬件进行一些介绍。 | ||
|
||
下面是 Arduino Uno 的引脚图: | ||
|
||
![Arduino引脚图](images/1-9.png) | ||
|
||
可以发现 Arduino Uno 有以下几个引脚分布: | ||
|
||
- GPIO | ||
- **Digital(D0-D19)** X 20 | ||
- **ADC(A0-A5)** X 6 | ||
- **PWM(D3,D5,D6,D9,D10,D11)** X 6 | ||
- **UART(D0,D1)** X 1 | ||
- **I2C(SCL-A5,SDA-A4)** X 1 | ||
- **SPI(MOSI-D11,MISO-D12,SCK-D13,CS-10)** X 1 | ||
- Power | ||
- **VIN** | ||
- **GND** | ||
- **5V** | ||
- **3.3V** | ||
- **AREF** | ||
|
||
Arduino 开发板有一个板载 LED,接在**D13 引脚**上,你也可以通过**LED_BUITIN**进行访问。另外还有两个 LED,分别是 RX 和 TX 的指示灯,当进行数据传输的时候对应的 LED 会闪烁。还有一个电源指示灯,通电后会点亮。 | ||
|
||
Arduino Uno 是一个 5V 的单片机,IO 口高电平时 5V,开发板上还有一个 3.3V 的电源接口给 3.3V 的设备进行供电。 | ||
|
||
如果你没有 5V 的电源,那你还可以通过 VIN 口输入 5-12V 的电压,Arduino 开发板上有一个 5V 的降压芯片。 | ||
|
||
## 3. Arduino IDE | ||
|
||
Arduino IDE 是一个开源的软件,它使编写代码和上传到开发板变得容易。该工具不仅可以为所有的 Arduino 开发板开发和调试代码,而且社区也为很多其他平台开发了 Arduino 支持库,如 ESP32, STM32, Raspberry Pi Pico 等。 | ||
|
||
### 下载链接 | ||
|
||
- Windows: [`点击下载`](https://downloads.arduino.cc/arduino-1.8.19-windows.exe) | ||
- Linux: [`点击下载`](https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz) | ||
- MacOS: [`点击下载`](https://downloads.arduino.cc/arduino-1.8.19-macosx.zip) | ||
|
||
下面是 Arduino IDE 的基本信息,关于该 IDE 的更多使用可以访问官方教程:[Arduino IDE Guide](https://www.arduino.cc/en/Guide) | ||
|
||
![Arduino IDE](images/1-10.png) | ||
|
||
### Arduino 2.x | ||
|
||
Arduino 2.x 是 Arduino IDE 的最新版本,使用 electron 开发。和 1.x 相比速度更快,功能更强大,具有更现代的编辑器,它还加入了代码自动补全、代码导航、实时调试器等功能。 | ||
|
||
Arduino 2.x 的正式版还在开发中,但是如果想抢先体验,可以访问 [`Github releases 页面`](https://github.com/arduino/arduino-ide/releases) 下载最新的 RC(Release Candidate) 版本。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
title: 第一个程序Blink | ||
--- | ||
|
||
# 第一个程序 Blink | ||
|
||
## 1. Blink | ||
|
||
几乎每一个学习单片机都要做的程序——点灯,下面是一个经典的点亮板载 LED 的 Arduino 程序: | ||
|
||
```cpp | ||
int led = 13; | ||
|
||
// the setup routine runs once when you press reset: | ||
void setup() { | ||
// initialize the digital pin as an output. | ||
pinMode(led, OUTPUT); | ||
} | ||
|
||
// the loop routine runs over and over again forever: | ||
void loop() { | ||
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) | ||
delay(1000); // wait for a second | ||
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | ||
delay(1000); // wait for a second | ||
} | ||
``` | ||
|
||
学过 C/C++的应该对其中大部分都可以理解,这里值得一提的是,setup 函数中的代码仅会执行一次,而 loop 函数中的内容会不断地反复执行其中的代码。 | ||
|
||
同时,每一个 Ardino 程序都必须 setup 和 loop 这两个函数,Arduino 文件的后缀名是`.ino`。 | ||
|
||
里面还有三个大家没有见过的函数,这是 Arduino 内置的函数,更多的函数后面会介绍,我们先看这三个函数。 | ||
|
||
## 2. pinMode()函数 | ||
|
||
语法: | ||
|
||
```cpp | ||
pinMode(pin,mode); | ||
``` | ||
pin 参数:这个函数用来配置某个引脚的功能模式,在 AVR 单片机中可以设置 0-13,A0-A5。 | ||
mode 参数:AVR 单片机中有以下三种引脚模式模式: | ||
- **OUTPUT** | ||
- **INPUT** | ||
- **INPUT_PULLUP** | ||
在上面的例子中就是使用了 OUTPUT 模式,也就是输出模式,让该引脚可以输出 0V 或者 5V。 | ||
另外两种模式,我们后面章节再讲。 | ||
## 3. digitalWrite()函数 | ||
语法: | ||
```cpp | ||
digitalWrite(pin,value); | ||
``` | ||
|
||
在将引脚设置为输出模式后,我们就可以通过 digitalWrite()函数决定引脚的输出状态。 | ||
|
||
pin 参数:需要输出的引脚号。 | ||
|
||
value 参数:需要对应引脚输出的状态,value 只能是一个布尔值,也就是 0 和非 0。当 value 为 0 时,输出为 0V,当 value 为非 0 时,输出 5V。 | ||
|
||
所以`digitalWrite(led, HIGH)`就是输出 5V,点亮 LED,`digitalWrite(led, LOW)`就是输出 0V,熄灭 LED。在 Arduino 中,`HIGH=1,LOW=0`。 | ||
|
||
## 4. delay()函数 | ||
|
||
语法: | ||
|
||
```cpp | ||
delay(ms); | ||
``` | ||
delay()是一个用于延时的函数,它会使得程序在该处延时一定的时间。 | ||
ms 参数:参数就是延时时间,单位是毫秒,数据类型为`unsigned long`。在 Arduino 中,你还可以使用`delayMicroseconds(us)`达到微秒级的延时,数据类型依然为`unsigned long`。 | ||
所以在上面的代码中`delay(1000)`就是延时一秒钟。 | ||
因此上面的代码整个看下来就是先对 13 号引脚进行配置,然后再循环中,先点亮 LED,延时一秒钟,再熄灭 LED,再延时一秒钟,然后循环往复。 | ||
整个程序的流程示意图如下: | ||
![Blink](images/2-1.png) |
Oops, something went wrong.