Basic Functions of Arduino
Basic Functions of Arduino
Configures the specified pin to behave either as an input or an output and other basic operation.
pinMode()
Description
Configures the specified pin to behave either as an input or an output. See the Digital Pins page for details on the functionality of the pins.
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP
. Additionally, the INPUT
mode explicitly disables the internal pullups.
Syntax
pinMode(pin, mode)
Parameters
pin
: the Arduino pin number to set the mode of.
mode
: INPUT
, OUTPUT
, or INPUT_PULLUP
. See the Digital Pins page for a more complete description of the functionality.
Returns
Nothing
digitalWrite()
Description
Write a HIGH
or a LOW
value to a digital pin.
If the pin has been configured as an OUTPUT
with pinMode()
, its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH
, 0V (ground) for LOW
.
If the pin is configured as an INPUT
, digitalWrite()
will enable (HIGH
) or disable (LOW
) the internal pullup on the input pin. It is recommended to set the pinMode()
to INPUT_PULLUP
to enable the internal pull-up resistor.
If you do not set the pinMode()
to OUTPUT
, and connect an LED to a pin, when calling digitalWrite(HIGH)
, the LED may appear dim. Without explicitly setting pinMode()
, digitalWrite()
will have enabled the internal pull-up resistor, which acts like a large current-limiting resistor.
Syntax
digitalWrite(pin, value)
Parameters
pin
: the Arduino pin number.
value
: HIGH
or LOW
.
Returns
Nothing
delay()
Description
Pauses the program for the amount of time (in milliseconds) specified as parameter. (There are 1000 milliseconds in a second.)
Syntax
delay(ms)
Parameters
ms
: the number of milliseconds to pause. Allowed data types: unsigned long
.
Returns
Nothing
Source: https://www.arduino.cc/reference/en
Leave a Reply
You must be logged in to post a comment.