当前位置:网站首页>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
边栏推荐
- LeetCode每日一题(1856. Maximum Subarray Min-Product)
- WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available. Prompt to upgrade pip
- Crawler career from scratch (3): crawl the photos of my little sister ③ (the website has been disabled)
- Hudi learning notes (III) analysis of core concepts
- Flink-CDC实践(含实操步骤与截图)
- Jenkins learning (III) -- setting scheduled tasks
- Integrated use of interlij idea and sonarqube
- Redis learning (I)
- CATIA automation object architecture - detailed explanation of application objects (III) systemservice
- C language programming specification
猜你喜欢
LeetCode每日一题(2090. K Radius Subarray Averages)
The rise and fall of mobile phones in my perspective these 10 years
Just graduate student reading thesis
软件测试工程师是做什么的 通过技术测试软件程序中是否有漏洞
Spark overview
PolyWorks script development learning notes (I) - script development environment
Detailed steps of windows installation redis
Spark structured stream writing Hudi practice
Flink学习笔记(八)多流转换
数字身份验证服务商ADVANCE.AI顺利加入深跨协 推进跨境电商行业可持续性发展
随机推荐
PolyWorks script development learning notes (II) -treeview basic operations
LeetCode每日一题(985. Sum of Even Numbers After Queries)
Solve POM in idea Comment top line problem in XML file
Crawler career from scratch (I): crawl the photos of my little sister ① (the website has been disabled)
Hudi learning notes (III) analysis of core concepts
[point cloud processing paper crazy reading classic version 7] - dynamic edge conditioned filters in revolutionary neural networks on Graphs
Windows安装Redis详细步骤
npm install安装依赖包报错解决方法
Jenkins learning (II) -- setting up Chinese
软件测试工程师是做什么的 通过技术测试软件程序中是否有漏洞
MySQL installation and configuration (command line version)
2022-2-14 learning xiangniuke project - generate verification code
[point cloud processing paper crazy reading frontier version 11] - unsupervised point cloud pre training via occlusion completion
IDEA 中使用 Hudi
Idea uses the MVN command to package and report an error, which is not available
Move anaconda, pycharm and jupyter notebook to mobile hard disk
LeetCode每日一题(2090. K Radius Subarray Averages)
LeetCode每日一题(2109. Adding Spaces to a String)
2022-2-13 learning xiangniuke project - version control
The server denied password root remote connection access