当前位置:网站首页>Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 1 -- establishment of engineering template -template
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 1 -- establishment of engineering template -template
2022-07-03 09:28:00 【Taodream】
First, build the development environment :https://blog.csdn.net/felix_tao/article/details/113092886
First step : Build a new project .
1) Project name Name:template
2) Development board Board:NodeMCU 1.0(ESP-12E Module)
3) frame Framework:Arduino
The second step : Copy in routine Blink Code to src->main.cpp in .
1) find Blink Routine path C:\Users\felix\.platformio\packages\framework-arduinoespressif8266\libraries\esp8266\examples\Blink
2) Use Nodepad++ open , Copy the code inside to src->main.cpp in , Be careful :main.cpp Do not delete the header file in .
Blink Routine code :
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is active low on the ESP-01)
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}3) stay Blink Add serial port printing on the basis , The sorted code is as follows .
Macro definition #define LED_BUILTIN 2, It can be added or not , Because in pins_arduino.h There will also be definitions in .
Be careful : Macro definition added #define LED_BUILTIN 2, It is impossible to jump to the definition , Need to be commented out , To jump .
main.cpp Code :
#include <Arduino.h>
//#define LED_BUILTIN 2 //ESP-12E The module itself LED, Corresponding GPIO2, Low level light
//#define LED_BUILTIN 16 //nodemcu-esp8266 The development board extends LED, Corresponding GPIO16, Low level light
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);// Serial port baud rate configuration
pinMode(LED_BUILTIN, OUTPUT);// Set the pin to output mode
}
void loop()
{
// put your main code here, to run repeatedly:
Serial.print("Hello world!\r\n");// Serial printing
// control LED Light flashing
digitalWrite(LED_BUILTIN, HIGH);// close LED The lamp
delay(1000);
digitalWrite(LED_BUILTIN, LOW); // open LED The lamp
delay(1000);
}pins_arduino.h Code ( It doesn't need to be modified ):
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#define PIN_WIRE_SDA (4)
#define PIN_WIRE_SCL (5)
static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;
#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif
#define LED_BUILTIN_AUX 16
static const uint8_t D0 = 16;
static const uint8_t D1 = 5;
static const uint8_t D2 = 4;
static const uint8_t D3 = 0;
static const uint8_t D4 = 2;
static const uint8_t D5 = 14;
static const uint8_t D6 = 12;
static const uint8_t D7 = 13;
static const uint8_t D8 = 15;
static const uint8_t D9 = 3;
static const uint8_t D10 = 1;
#include "../generic/common.h"
#endif /* Pins_Arduino_h */platformio.ini Code :
modify VSCODE Serial port monitor baud rate , Add the code :monitor_speed = 115200 #VSCODE Serial port monitor baud rate
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
monitor_speed = 115200 #VSCODE Serial port monitor baud rate The third step : compile 、 download 、 function .
1) After downloading the code successfully , You can see the LED Light flashing .
2)VSCODE Open the serial port monitor , You can see the print Hello world!.
Project source code download :https://download.csdn.net/download/felix_tao/14946368
边栏推荐
- Spark overview
- Install third-party libraries such as Jieba under Anaconda pytorch
- PowerDesigner does not display table fields, only displays table names and references, which can be modified synchronously
- 用Redis实现分布式锁
- [set theory] order relation (eight special elements in partial order relation | ① maximum element | ② minimum element | ③ maximum element | ④ minimum element | ⑤ upper bound | ⑥ lower bound | ⑦ minimu
- PolyWorks script development learning notes (II) -treeview basic operations
- Overview of database system
- 专利查询网站
- 1922. Count Good Numbers
- IDEA 中使用 Hudi
猜你喜欢

PolyWorks script development learning notes (II) -treeview basic operations

Go language - Reflection

Crawler career from scratch (I): crawl the photos of my little sister ① (the website has been disabled)

Computing level network notes

Flink学习笔记(十一)Table API 和 SQL

Solve POM in idea Comment top line problem in XML file

Just graduate student reading thesis

Overview of image restoration methods -- paper notes
![[point cloud processing paper crazy reading classic version 13] - adaptive graph revolutionary neural networks](/img/61/aa8d0067868ce9e28cadf5369cd65e.png)
[point cloud processing paper crazy reading classic version 13] - adaptive graph revolutionary neural networks

Run flash demo on ECS
随机推荐
基于opencv实现桌面图标识别
LeetCode每日一题(968. Binary Tree Cameras)
Hudi learning notes (III) analysis of core concepts
npm install安装依赖包报错解决方法
Data mining 2021-4-27 class notes
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available. Prompt to upgrade pip
unbuntu(debian)下TFTP服务器搭建及测试
LeetCode每日一题(2090. K Radius Subarray Averages)
The less successful implementation and lessons of RESNET
Vscode编辑器右键没有Open In Default Browser选项
PIP configuring domestic sources
CATIA automation object architecture - detailed explanation of application objects (III) systemservice
LeetCode每日一题(1856. Maximum Subarray Min-Product)
一款开源的Markdown转富文本编辑器的实现原理剖析
Numerical analysis notes (I): equation root
Quickly use markdown to edit articles
Powerdesign reverse wizard such as SQL and generates name and comment
[kotlin puzzle] what happens if you overload an arithmetic operator in the kotlin class and declare the operator as an extension function?
LeetCode每日一题(1996. The Number of Weak Characters in the Game)
Install third-party libraries such as Jieba under Anaconda pytorch