zoukankan      html  css  js  c++  java
  • Arduino-1 点亮小灯

    Arduino 点亮小灯

    1.程序代码:

    int delayTime = 3000;
    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin 8 as an output.
      pinMode(8, OUTPUT);
    }
    
    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(8, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(delayTime);                       // wait for a second
      digitalWrite(8, LOW);    // turn the LED off by making the voltage LOW
      delay(delayTime);                       // wait for a second
    }
    

    2.程序说明:

    int delayTime 为自定义全局变量

    void setup 为arduino 内置的函数名,表示初始化调用的函数,类似构造函数

    void loop 为函数循环执行的部分,可以类比接口,要实现的方法

    pinMode 为Arduino 内置的函数,具体的使用方法可以查看这个地址:https://www.arduino.cc/reference/en/

    语法为: pinMode(pin, mode)

    原文:Configures the specified pin to behave either as an input or an output
    配置指定的引脚号作为输入模式或者输出模式
    
    • pin 为 Arduino的引脚号
    • mode: 模式,
      • INPUT
      • OUTPUT
      • INPUT_PULLUP
    • pinMode模式的是input模式,input的模式下,pin引脚上的电阻很大 ,output模式电阻会变小, 可以简单的理解为pinMode是设置引脚的电阻的,但是他不会给改变电压

    digitalWrite : 同样是arduino的一个内置函数,他可以改变引脚上的电压状态,两种状态,一种是HIGH,一种是LOW, 不同的是high有的时候是5v,有的是3v,而low,都是0v

    3. 图片

  • 相关阅读:
    JavaWeb核心之Servlet
    Http&Tomcat
    XML&反射
    JDBC连接池和DBUtils
    JDBC
    testng依赖
    java mysql
    eclipse自动补全的设置
    java Logger 的使用与配置
    python数据持久存储:pickle模块的基本使用
  • 原文地址:https://www.cnblogs.com/callmelx/p/13817053.html
Copyright © 2011-2022 走看看