前期编写准备
打开VS code 选择一个文件夹
(此处可参考博主之前所写的一篇博客,从样例中拷贝一份blink文件,存入另外一个文件夹中便于使用,同时可修改文件名作为测试,此处我将它更改为了blinktoblinktest2)
打开 blinktoblinktest2 依据电路板的引脚修改可执行代码,我设计的是不同的开关启动,能够引起不同的发光二极管按照一定规律闪烁和蜂鸣器的响动
选择好端口com 4之后,再点击ESP-IDF Build project(即最下方垃圾桶右侧处)进行编译,编译成功结果如下图
代码如下,仅供参考
此代码测试情况良好,不过也存在了一定的缺陷,有待调试
/* GPIO Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#define GPIO_OUTPUT_IO_LED2 15
#define GPIO_OUTPUT_IO_LED3 2
#define GPIO_OUTPUT_IO_LED4 4
#define GPIO_OUTPUT_IO_BEEP 19
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_OUTPUT_IO_LED2) | (1ULL<<GPIO_OUTPUT_IO_LED3) | (1ULL<<GPIO_OUTPUT_IO_LED4)| (1ULL<<GPIO_OUTP