Arduino

All extension methods and properties in the arduino library depend on the Arduino extension package. Please import Arduino before use.

import arduino

Arduino supports burning firmware 'mCookie' and 'mCookie extension'. In the text, the parameters that support the float type or the valid string float type are directly converted into int type in actual operation. For example, 2.3 is equivalent to 2, '2.6' is equivalent to 2

1、Set the pin high and low

Pin

arduino.digitalWrite(port, type)
"""
    port : The port to set the pin status, the default is 2/3, the parameter is 2
    type : Pin level status, including 0 (Low), 1 (High)
    Function : Used to set the level status of the specified port
    Parameter type : port, type are applicable to int, float, and pure numeric strings
    Applicable modules : Sensor expansion board
"""

2、Read digital pin

Pin

arduino.digitalRead(port)
"""
    port : The port to get the pin status, the default is 2/3, the parameter is 2
    Function : Read the current switch status of the specified pin
    Return value type : Return value type contains 0 (not working status), 1 (working status)
    Parameter type : port for int, float, and pure numeric strings
"""

3、Determine pin high and low

Pin

arduino.digitalRead(port) == type
"""
    port : The port to get the pin status, the default is 2/3, the parameter is 2
    type : Pin level status, including 0 (Low), 1 (High)
    Function : Read the current switch status of the specified pin
    Return value type : Return value type contains 0 (not working status), 1 (working status)
    Parameter type : port for int, float, and pure numeric strings
    Applicable modules : Sensor expansion board
"""

This is a combined instruction that is generated by a combination of a pin level status read command and a decision command. When using, you can refer to and modify the judgment instructions to achieve the special needs.

4、Read analog pin

Pin

rduino.analogRead(port)
"""
    port: Analog pin port, default is A0, parameter is 0
    Function : Read the input value of the specified analog pin
    Return value type : Return type is int
    Parameter type : port for int, float, and pure numeric strings
"""

5、Set the pin PWM value

Pin

arduino.analogWrite(port, pwm)
"""
    Port : pin port, default is 3, parameter is 3
    pwm : Output pwm value
    Function : Output pwm value of a specific frequency to a specified pin
    Parameter type : port, pwm for int, float and pure numeric strings
"""

6、Mapping

Pin

arduino.map(num, snum1, snum2, enum1, enum2)
"""
    Num : the target value, which belongs to the data range of snum1 to snum2
    Snum1 : the starting value before mapping
    Snum2 : the termination value before mapping
    Enum1 : the starting value to be mapped
    Enum2 : the ending value to be mapped
    Function : Map the value num in the range of snum1 to snum2 to the range of enum1 to enum2
    Return value type : Return type is int
    Parameter types: num, snum1, snum2, enum1, enum2 for int, float, and pure numeric strings
"""

This function mainly acts as a mapping value to limit the value to a valid or actual range. For example, mapping 500 in the range of 1-1000 to 1-100 is 50. 500 is the num herein, 1-1000 to snum1-snum2,1-100 enum1-enum2,50 a

7、Constraint

Pin

max(min(max_num, num), min_num)
"""
    Num : the value to be constrained
    Min_num : minimum constraint range
    Max_num : maximum constraint range
    Function : The value to be constrained, constrained within the specified range
    Return value type : Return value is int
    Parameter type : num, min_num, max_num
"""

This is a composite function composed of min() and max(). The main function is to limit the target value within the specified range. When the target value is less than the minimum value within the limited range, the minimum value of the limited range is taken,and vice versa