《Hello Arduino》数电I/O

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xxxxxx91116/article/details/41596827

Hello Arduino

这是一篇小白Arduino文章,记录一些常用的Arduino函数和应用场景。

Arduino API主页:http://arduino.cc/en/Reference/HomePage


一:数电I/O

1.1 pinMode()

描述:设置pin引脚为输入或者输出模式,也就是Arduino上面的那些引脚

原型:pinMode(pin, mode)

pin:要使用的引脚号

mode: INPUTOUTPUT, or INPUT_PULLUP(设置Arduino的上拉电阻有效)

1.2 digitalWrite()

描述:如果之前使用pinMode设置的是OUTPUT模式,那么向pin引脚输出高电平(5V)或者(0V);

如果之前使用pinMode设置的是INPUT模式,那么设置为HIGH将会激活其内部的上拉电阻,设置为LOW   会使上拉电阻失效

原型:digitalWrite(pin, value)

pin:要使用的引脚号

value:High or Low

上拉电阻,下拉电阻主要是为了电路输出确定的高电平或者低电平,因为数字电路就是0或者1.

1.3 digitalRead(pin)

描述:读取pin引脚的值,只有HIGH或者LOW

原型:int digitalRead(pin)

pin:要使用的引脚号

返回值:High or Low





猜你喜欢

转载自blog.csdn.net/xxxxxx91116/article/details/41596827