现在学做网站赚钱吗/百度seo规则最新
学院 | 班级 | 学号 | |||
姓名 | 日期 | 成绩 | |||
实验题目 | 按键和中断 | ||||
实验目的 | 实现闪灯功能转换 | ||||
硬件原理 | 无 | ||||
关键代码及注释 | /* Button Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached to pin 2. The circuit: * LED attached from pin 13 to ground * pushbutton attached to pin 2 from +3.3V * 10K resistor attached to pin 2 from ground * Note: on most Arduinos there is already an LED on the board attached to pin 13. created 2005 by DojoDave <http://www.0j0.org> modified 30 Aug 2011 by Tom Igoe modified Apr 27 2012 by Robert Wessels This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Button */ // constants won't change. They're used here to // set pin numbers: const int buttonPin = PUSH2; // the number of the pushbutton pin const int ledPin1 = GREEN_LED; // the number of the LED pin const int ledPin2 = YELLOW_LED; const int ledPin3 = RED_LED; int ledState = LOW; int ledState1 = LOW; int ledState2 = LOW; int ledState3 = LOW; volatile bool state = HIGH; int count = 0; // variables will change: int buttonState = 0; // variable for reading the pushbutton status long previousMillis = 0; // will store last time LED was updated long term = 0; // the follow variables is a long because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. long interval = 1000; void setup() { // initialize the LED pin as an output: pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); //digitalWrite(ledPin,state); pinMode(buttonPin,INPUT_PULLUP); attachInterrupt (buttonPin ,blink ,RISING); } void blink(){ state = !state; } void loop(){ unsigned long currentMillis = millis();
if(state==HIGH){ if(currentMillis - previousMillis > interval) { // save the last time you blinked the LED previousMillis = currentMillis; // if the LED is off turn it on and vice-versa: if (ledState == LOW) ledState = HIGH; else{ ledState = LOW;
} // set the LED with the ledState of the variable: digitalWrite(ledPin1, ledState); digitalWrite(ledPin2, ledState); digitalWrite(ledPin3, ledState); } } else{ if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; if (ledState1 == LOW && ledState2 == LOW && ledState3 == LOW) ledState1 = HIGH; else if(ledState1 == HIGH){ ledState1 = LOW; ledState2 = HIGH; } else if(ledState2 == HIGH){ ledState2 = LOW; ledState3 = HIGH;
} else if(ledState3 == HIGH){ ledState3 = LOW; ledState1 = HIGH;
} digitalWrite(ledPin1, ledState1); digitalWrite(ledPin2, ledState2); digitalWrite(ledPin3, ledState3); } } } | ||||
实验步骤 | 在上次作业基础上加上了按钮,中断 | ||||
实验结果 | ![]() ![]() ![]() ![]() ![]() ![]() | ||||
思考与反馈 | 无 |
相关文章:

hdu物联网硬件实验3 按键和中断
学院 班级 学号 姓名 日期 成绩 实验题目 按键和中断 实验目的 实现闪灯功能转换 硬件原理 无 关键代码及注释 /* Button Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached…...

pytorch通过 tensorboardX 调用 Tensorboard 进行可视化
示例 import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader from torchvision import datasets, transformsfrom tensorboardX import SummaryWriter# 定义神经网络模型 class SimpleCNN(nn.Module):def __init__(self):…...

linux查看目录下的文件夹命令,find 查找某个目录,但是不包括这个目录本身?
linux查看目录下的文件夹命令,find 查找某个目录,但是不包括这个目录本身? Linux中查看目录下的文件夹的命令是使用ls命令。ls命令用于列出指定目录中的文件和文件夹。通过不同的选项可以实现显示详细信息、按照不同的排序方式以及使用不同的…...

单一设备上的 2 级自动驾驶:深入探究 Openpilot 的奥秘
Level 2 Autonomous Driving on a Single Device: Diving into the Devils of Openpilot 单一设备上的 2 级自动驾驶:深入探究 Openpilot 的奥秘 Abstract Equipped with a wide span of sensors, predominant autonomous driving solutions are becoming more m…...

向github远程仓库中push,要求使用token登录
Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. 如上,当向github远程仓库push时,输入github的用户名和密码出现如上错误,要求使用token登录,此时只需要用户…...

最全windows提权总结(建议收藏)
当以低权用户进去一个陌生的windows机器后,无论是提权还是后续做什么,第一步肯定要尽可能的搜集信息。知己知彼,才百战不殆。 常规信息搜集 systeminfo 查询系统信息hostname 主机名net user 查看用户信息netstat -ano|find "3389&quo…...

Could not find Chrome (ver.xxxxx). This can occur if either\n
文章目录 错误解决方法 错误 Could not find Chrome (ver. 119.0.6045.105). This can occur if either\n 1. you did not perform an installation before running the script (e.g. npx puppeteer browsers install chrome) or\n 2. your cache path is incorrectly configu…...

Conmi的正确答案——ESP32-C3开启安全下载模式
IDF版本:4.4.7 注意事项:一旦烧录“安全下载模式”,模组将无法被读取或清理,只能通过eclipse原项目烧录程序进行重新烧录,无法再烧录其他固件。 20240703110201——追加解法,暂时无法解安全下载模式 &…...

从零开始实现大语言模型(一):概述
1. 前言 大家好,我是何睿智。我现在在做大语言模型相关工作,我用业余时间写一个专栏,给大家讲讲如何从零开始实现大语言模型。 从零开始实现大语言模型是了解其原理及领域大语言模型实现路径的最好方法,没有之一。已有研究证明&…...
科普文本分类背后的数学原理——最新版《数学之美》第14、15章读书笔记
新闻分类,或广义上的文本分类,其核心任务是根据文本内容将相似文本聚合在同一类别中。在新闻领域,这意味着将报道划分为财经、体育、军事等不同主题。人类执行此任务时,通过阅读和理解新闻的主旨来进行归类。然而,作者…...

华为云生态和快速入门
华为云生态 新技术催生新物种,新物种推动新生态 数字技术催生各类运营商去重塑并颠覆各行业的商业模式 从业务层面看,企业始终如一的目标是业务增长和持续盈利,围绕这些目标衍生出提质、增效、降本、安全、创新和合规的业务诉求,…...

卷积神经网络——LeNet——FashionMNIST
目录 一、整体结构二、model.py三、model_train.py四、model_test.py GitHub地址 一、整体结构 二、model.py import torch from torch import nn from torchsummary import summaryclass LeNet(nn.Module):def __init__(self):super(LeNet,self).__init__()self.c1 nn.Conv…...

k8s-第十二节-DaemonSet
DaemonSet是什么? DaemonSet 是一个确保全部或者某些节点上必须运行一个 Pod的工作负载资源(守护进程),当有node(节点)加入集群时, 也会为他们新增一个 Pod。 下面是常用的使用案例: 可以用来部署以下进程的pod 集群守护进程,如Kured、node-problem-detector日志收集…...

Mysql-内置函数
一.什么是函数? 函数是指一段可以直接被另外一段程序调用的程序或代码。 mysql内置了很多的函数,我们只需要调用即可。 二.字符串函数 MySQL中内置了很多字符串函数: 三.根据需求完成以下SQL编写 由于业务需求变更,企业员工的工号,统一为5位数,目前不足5位数的全…...

新浪API系列:支付API打造无缝支付体验,畅享便利生活(3)
在当今数字化时代,支付功能已经成为各类应用和平台的必备要素之一。作为开发者,要构建出安全、便捷的支付解决方案,新浪支付API是你不可或缺的利器。新浪支付API提供了全面而强大的接口和功能,帮助开发者轻松实现在线支付的集成和…...

终于弄明白了什么是EI!
EI是Engineering Index的缩写,中文意为“工程索引”,是由美国工程信息公司(Engineering Information, Inc.)编辑出版的著名检索工具。它始创于1884年,拥有超过一个世纪的历史,是全球工程界最权威的文献检索系统之一。EI虽然名为“…...

微信小程序常见页面跳转方式
1. wx.navigateTo() 保留当前页,跳转到不是 tabbar 的页面,会新增页面到页面栈。通过返回按钮或 wx.navigateBack()返回上一个页面。 2. wx.redirectTo() 跳转到不是 tabbar 的页面,替换当前页面。不能返回。 3. wx.switchTab() 跳转到 …...

Vim常用整理快捷键
一、光标跳转 参数释义w下一行首字符e下一行尾字符0跳至行首$跳至行尾gg跳至文首5gg跳至第五行gd标记跳转到当前光标所在的变量的定义位置fn找当前行后的n字符,跳转到n字符位置 二、修改类操作 参数释义D删除光标之后的字符dd删除整行x删除当前字符yy复制一行p向…...

【docker 把系统盘空间耗没了!】windows11 更改 ubuntu 子系统存储位置
系统:win11 ubuntu 22 子系统,docker 出现问题:系统盘突然没空间了,一片红 经过排查,发现 AppData\Local\packages\CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc\ 这个文件夹竟然有 90GB 下面提供解决办法 步…...

前端如何让网页页面完美适配不同大小和分辨率屏幕
推荐使用postcss插件,它会自动将项目所有的px单位统一转换为vw等单位(包括npm安装的第三方组件),从而实现适配,具体配置规则可参考官网或npm网站介绍。 另外对于大屏的适配,需要缩放网页,可使用…...

gitlab-runner安装部署CI/CD
手动安装 卸载旧版: gitlab-runner --version gitlab-runner stop yum remove gitlab-runner下载gitlab对应版本的runner # https://docs.gitlab.com/runner/install/bleeding-edge.html#download-any-other-tagged-releasecurl -L --output /usr/bin/gitlab-run…...

数据分析案例-2024 年全电动汽车数据集可视化分析
🤵♂️ 个人主页:艾派森的个人主页 ✍🏻作者简介:Python学习者 🐋 希望大家多多支持,我们一起进步!😄 如果文章对你有帮助的话, 欢迎评论 💬点赞Ǵ…...

H桥驱动器芯片详解
H桥驱动器芯片详解 上一篇文章讲解了H桥驱动器的控制原理,本文以汽车行业广泛应用的DRV8245芯片为例,详细讲解基于集成电路的H桥驱动器芯片。 1.概述 DRV824x-Q1系列器件是德州仪器(TI)的一款专为汽车应用设计的全集成H桥驱动器…...

哪个充电宝口碑比较好?怎么选充电宝?2024年口碑优秀充电宝推荐
在如今快节奏的生活中,充电宝已然成为我们日常生活中的必备品。然而,市场上充电宝品牌众多,质量参差不齐,如何选择一款安全、可靠且口碑优秀的充电宝成为了消费者关注的焦点。安全性能不仅关系到充电宝的使用寿命,更关…...

Memcached 介绍与详解及在Java Spring Boot项目中的使用与集成
Memcached 介绍 Memcached 是一种高性能的分布式内存对象缓存系统,主要用于加速动态Web应用以减少数据库负载,从而提高访问速度和性能。作为一个开源项目,Memcached 被广泛应用于许多大型互联网公司,如Facebook、Twitter 和 YouT…...

淮北在选择SCADA系统时,哪些因素会影响其稳定性?
关键字:LP-SCADA系统, 传感器可视化, 设备可视化, 独立SPC系统, 智能仪表系统,SPC可视化,独立SPC系统 在选择SCADA系统时,稳定性是一个关键因素,因为它直接影响到生产过程的连续性和安全性。以下是一些影响SCADA系统稳定性的因素: 硬件质量…...

Linux: 命令行参数和环境变量究竟是什么?
Linux: 命令行参数和环境变量究竟是什么? 一、命令行参数1.1 main函数参数意义1.2 命令行参数概念1.3 命令行参数实例 二、环境变量2.1 环境变量概念2.2 环境变量:PATH2.2.1 如何查看PATH中的内容2.2.2 如何让自己的可执行文件不带路径运行 2.3 环境变量…...

数学系C++ 类与对象 STL(九)
目录 目录 面向对象:py,c艹,Java都是,但c是面向过程 特征: 对象 内敛成员函数【是啥】: 构造函数和析构函数 构造函数 复制构造函数/拷贝构造函数: 【……】 实参与形参的传递方式:值…...

CSS技巧专栏:一日一例 2.纯CSS实现 多彩边框按钮特效
大家好,今天是 CSS技巧一日一例 专栏的第二篇《纯CSS实现多彩边框按钮特效》 先看图: 开工前的准备工作 正如昨日所讲,为了案例的表现,也处于书写的习惯,在今天的案例开工前,先把昨天的准备工作重做一遍。 清除浏览器的默认样式定义页面基本颜色设定body的样式清除butt…...

JCEF 在idea 开发 java 应用
JCEF(Java Chromium Embedded Framework)是一个Java库,用于在Java应用程序中嵌入Chromium浏览器引擎。如果您想在IDEA开发环境中使用JCEF,您可以按照以下步骤进行操作: 1. 下载JCEF库文件:您可以从JCEF的官…...