arduino基础-函数(arduino基础-函数).doc

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

arduino基础-函数(arduino基础-函数)

Input output function

Arduino contains a switching function of some processing input and output, is believed to have the book from a program example・

PinMode (pin, mode)

Specifies the digital foot (digital, pin) as input or output・

Example:

PinMode (7, INPUT); / / pin 7 is set as input mode

DigitalWrite (pin, value)

Specifies the number of pins to be on or off. The pin must first

be passed through the pinMode as input or output mode, and the digitalWrite will take effect・

Example:

DigitalWrite (8, HIGH) ; / / set the high potential output pin 8

Int digitalRead (PIN)

Read the value of the input pin and return HIGH when it is sensed that the foot is at high potentia 1. Otherwise, it will return LOW.

Example:

Vai 二digitalRead (7) ; / / read pin 7 values and assigned to val Int analogRead (PIN)

Read the voltage of the analog foot and return a value from 0 to 1023 to indicate the corresponding 0 to 5 voltage value・

Example:

Val 二analogRead (0) ; / / read analog pin 0 values and assigned to the variable val

AnalogWrite (pin, value)

Change the output voltage of the PWM pin, and the feet are usually at 3, 5, 6, 9, 10 and 11. The Value range is 0-255, for example, the output voltage is 2.5 volts (V), and the value is about 128.

Example:

AnalogWrite (9128); / / output voltage of about 2. 5 volts (V)

Unsigned, long, pulseln (pin, value)

Sets the duration of the read position of the foot, for example, when an infrared or accelerometer is used to measure a certain value, without changing the state in the time unit・

Example:

Time 二pulsein (7, HIGH) : / / set foot 7 state in the unit of

time is HIGH

ShiftOut (dataPin, clockPin, bitOrder, value)

The data is passed to a register used to extend the digital output ・ The function uses one foot to represent the data and one foot to indicate the pulse・ BitOrder is used to represent the movement of bits (the lowest significant bit of LSBFIRST or the most significant bit of MSBFIRST), and finally the value output in byte form・ This function is usually used in the output of the extended digit・

Example:

ShiftOut (dataPin, clockPin, LSBFIRST, 255);

Time function

Control and calculate the time during execution of the chip

Unsigned, long, millis ()

The return chip begins to execute to the current millisecond

Example:

Duration 二millis (-lastTime); / / said that since the

〃lastTime〃the present time

Delay (MS)

相关文档
最新文档