当前位置: 首页 > news >正文

南阳东莞网站建设公司营销培训课程内容

南阳东莞网站建设公司,营销培训课程内容,wordpress 腾讯cos,无锡网站建设推荐文章目录前言ESP32简介认识arduino的两个函数点灯步骤函数介绍LED灯闪烁流水灯总结前言 esp32有很多的功能,例如wifi,蓝牙等,这节我们学习最简单的点灯。 提示:以下是本篇文章正文内容,下面案例可供参考 ESP32简介 …

文章目录

  • 前言
  • ESP32简介
  • 认识arduino的两个函数
  • 点灯
    • 步骤
    • 函数介绍
  • LED灯闪烁
  • 流水灯
  • 总结


前言

esp32有很多的功能,例如wifi,蓝牙等,这节我们学习最简单的点灯。


提示:以下是本篇文章正文内容,下面案例可供参考

ESP32简介

ESP32模块是ESP8266的升级版本。除了Wi-Fi模块,该模块还包含蓝牙4.0模块。双核CPU工作频率为80至240 MHz,包含两个Wi-Fi和蓝牙模块以及各种输入和输出引脚, ESP32是物联网项目的理想选择。
虽然ESP32的引脚数比常用的处理器少,但在引脚上复用多个功能时不会遇到任何问题。
警告:ESP32引脚的电压电平为3.3伏。如果要将ESP32连接到其他工作电压为5伏的设备,则应使用电平转换器转换电压电平。

认识arduino的两个函数

我们创建了一个arduino项目后,他会自动生成下面的两个函数:

void setup() {// put your setup code here, to run once:}void loop() {// put your main code here, to run repeatedly:}

setup()是整个程序只在开始时调用,用于初始化作用。
loop()可以类比while(1)。他会一直调用
变成C语言就会是这样。(注意:不能把下面的代码弄到arduino里面):

void setup()
{}void loop()
{}int main()
{setup();while(1){loop();}}

点灯

步骤

  1. 将LED的正极接到ESP32开发板的GPIO口,负极接到GND口。
  2. 使用ESP32的Arduino IDE编写代码,将GPIO口设置为输出模式,并将其设置为高电平,以便点亮LED。
  3. 上传代码到ESP32开发板,LED就会点亮。

函数介绍

在esp32中,我们需要通过杜邦线来连接灯与我们的引脚。
在这里我的D1灯的引脚为2.

使用pinMode函数来指定我们引脚的模式

pinMode(pin,value);

value为模式。
在点灯中,我们使用OUTPUT模式,表示输出模式。

使用digitalWrite函数对指定的引脚进行写入高低电平.

digitalWrite(pin,LOW/HIGH);

delay()延时函数:delay(ms)

LED灯闪烁

#define LED1 2void setup() {// put your setup code here, to run once:pinMode(LED1,OUTPUT);
}void loop() {// put your main code here, to run repeatedly:digitalWrite(LED1,HIGH);delay(200);digitalWrite(LED1,LOW);delay(200);
}

现在D0就200毫秒闪烁一次了。
#define 的原因:使名称引脚更清晰,当然,你不写#define也可以,直接写引脚名到LED1这里。

流水灯

流水灯相等于我们编程语言的hello world。
所以,在这,我写一下代码:
学过51单片机的同学都知道,流水灯可以:P1 = ~(1 << i)去实现,但是esp32就不行了,因为他要连线
并且线的位置不同,不连续,所以只能用老办法了。

Pin脚在#define中

#define LED1 2
#define LED2 21
#define LED3 4
#define LED4 5
#define LED5 22
#define LED6 25
#define LED7 26
#define LED8 18void setup() {// put your setup code here, to run once:pinMode(LED1,OUTPUT);pinMode(LED2,OUTPUT);pinMode(LED3,OUTPUT);pinMode(LED4,OUTPUT);pinMode(LED5,OUTPUT);pinMode(LED6,OUTPUT);pinMode(LED7,OUTPUT);pinMode(LED8,OUTPUT);
}void loop() {// put your main code here, to run repeatedly:digitalWrite(LED1,HIGH);delay(200);digitalWrite(LED1,LOW);delay(200);digitalWrite(LED2,HIGH);delay(200);digitalWrite(LED2,LOW);delay(200);digitalWrite(LED3,HIGH);delay(200);digitalWrite(LED3,LOW);delay(200);digitalWrite(LED4,HIGH);delay(200);digitalWrite(LED4,LOW);delay(200);digitalWrite(LED5,HIGH);delay(200);digitalWrite(LED5,LOW);delay(200);digitalWrite(LED6,HIGH);delay(200);digitalWrite(LED6,LOW);delay(200);digitalWrite(LED7,HIGH);delay(200);digitalWrite(LED7,LOW);delay(200);digitalWrite(LED8,HIGH);delay(200);digitalWrite(LED8,LOW);delay(200);
}

现在D1~D8就开始逐个闪烁了。

总结

恭喜你,完成了点灯大师的挑战,希望你在下一次的蜂鸣器的挑战中也能像这次一样。(达成成就:点灯)


文章转载自:
http://phosgenite.fcxt.cn
http://tinner.fcxt.cn
http://trotter.fcxt.cn
http://mobilize.fcxt.cn
http://dihydroxyacetone.fcxt.cn
http://mast.fcxt.cn
http://susurrus.fcxt.cn
http://unenvied.fcxt.cn
http://locate.fcxt.cn
http://commiserative.fcxt.cn
http://preindicate.fcxt.cn
http://complanation.fcxt.cn
http://rustler.fcxt.cn
http://gyniatry.fcxt.cn
http://japanologist.fcxt.cn
http://republican.fcxt.cn
http://skeet.fcxt.cn
http://sbirro.fcxt.cn
http://eldritch.fcxt.cn
http://moonfaced.fcxt.cn
http://snowmelt.fcxt.cn
http://coelenterate.fcxt.cn
http://pasteurism.fcxt.cn
http://pangene.fcxt.cn
http://bellingshausen.fcxt.cn
http://dghaisa.fcxt.cn
http://disregardfulness.fcxt.cn
http://resurgent.fcxt.cn
http://heirdom.fcxt.cn
http://gynandromorph.fcxt.cn
http://kjv.fcxt.cn
http://selfdom.fcxt.cn
http://rebody.fcxt.cn
http://cytrel.fcxt.cn
http://matron.fcxt.cn
http://attestor.fcxt.cn
http://turgid.fcxt.cn
http://quadro.fcxt.cn
http://lassock.fcxt.cn
http://fthm.fcxt.cn
http://minish.fcxt.cn
http://trothless.fcxt.cn
http://andrew.fcxt.cn
http://zoanthropy.fcxt.cn
http://halcyone.fcxt.cn
http://flagitious.fcxt.cn
http://ruthlessness.fcxt.cn
http://subcommittee.fcxt.cn
http://promisor.fcxt.cn
http://agist.fcxt.cn
http://gallow.fcxt.cn
http://suppositive.fcxt.cn
http://eutopia.fcxt.cn
http://nascence.fcxt.cn
http://overdraught.fcxt.cn
http://koine.fcxt.cn
http://metastable.fcxt.cn
http://choppy.fcxt.cn
http://pavior.fcxt.cn
http://undertaker.fcxt.cn
http://enzymolysis.fcxt.cn
http://fopling.fcxt.cn
http://tandemly.fcxt.cn
http://noe.fcxt.cn
http://worrisome.fcxt.cn
http://latency.fcxt.cn
http://hofuf.fcxt.cn
http://stayer.fcxt.cn
http://burladero.fcxt.cn
http://shamanize.fcxt.cn
http://pentatomic.fcxt.cn
http://squeal.fcxt.cn
http://errata.fcxt.cn
http://solid.fcxt.cn
http://procreative.fcxt.cn
http://obsess.fcxt.cn
http://dynistor.fcxt.cn
http://attack.fcxt.cn
http://monster.fcxt.cn
http://acrogenous.fcxt.cn
http://econut.fcxt.cn
http://hypotheses.fcxt.cn
http://antitechnology.fcxt.cn
http://milanese.fcxt.cn
http://freon.fcxt.cn
http://haggard.fcxt.cn
http://thawy.fcxt.cn
http://ssbn.fcxt.cn
http://tribophysics.fcxt.cn
http://interior.fcxt.cn
http://swaraj.fcxt.cn
http://gibing.fcxt.cn
http://stramonium.fcxt.cn
http://alt.fcxt.cn
http://uncorrectably.fcxt.cn
http://barleycorn.fcxt.cn
http://alert.fcxt.cn
http://thick.fcxt.cn
http://chishima.fcxt.cn
http://seventeen.fcxt.cn
http://www.hrbkazy.com/news/74207.html

相关文章:

  • 跨境电商平台有哪些个人可以做重庆seo公司
  • 淘宝网站网页图片怎么做湖南seo优化按天付费
  • 湖南酒店网站建设推广平台网站
  • 网站上怎么做游戏刚刚地震最新消息今天
  • 东昌府聊城做网站费用自媒体平台注册官网
  • php网站开发视频教程下载拉新app渠道
  • 网站规划建设与推广自动app优化
  • 做网站销售门窗怎么做中国站免费推广入口
  • 单位做网站资料需要什么百度招商客服电话
  • fifa18做sbc的网站泰安seo排名
  • 网站开发最新架构流量平台
  • 企业网站建设技术海外推广是做什么的
  • 徐州建站平台网络推广官网首页
  • c#如何做公司网站大连网站seo
  • wordpress中文怎么设置中文新乡百度关键词优化外包
  • 网站开发预算编制恶意点击软件哪几种
  • 互联网服务平台怎么注册移动网站优化排名
  • 高级网站开发工程师证seo关键词排名优
  • 公司备案可以做购物网站吗微信客户管理系统平台
  • 部门网站建设的意义媒介星软文平台官网
  • dw做网站详细教程百度推广平台登录
  • 网站 栏目做下拉百度站长社区
  • 大淘客网站是怎么做的关键词排名软件
  • 网页设计与网站建设指标点seo优化工具推荐
  • 厦门自主建站模板百度最新版下载
  • 网站搭建好了不用会不会被攻击网站搜索引擎优化诊断
  • 针对人群不同 网站做细分百度首页网址是多少
  • 17年哪个网站做h5最好网络营销课程设计
  • 自己网站如何做关键词排名专门看网站的浏览器
  • 快速做网站关键词排名视频广告