0% found this document useful (0 votes)
62 views7 pages

Car Code Details

Serial.begin(9600) initializes serial communication between the Arduino and computer at a baud rate of 9600 bits per second. pinMode() configures a pin as an input, output, or input with internal pull-up resistor. Serial.available() returns the number of bytes available to read from the serial port receive buffer.

Uploaded by

esha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views7 pages

Car Code Details

Serial.begin(9600) initializes serial communication between the Arduino and computer at a baud rate of 9600 bits per second. pinMode() configures a pin as an input, output, or input with internal pull-up resistor. Serial.available() returns the number of bytes available to read from the serial port receive buffer.

Uploaded by

esha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Serial.begin(9600); passes the value 9600 to the speed parameter.

This tells the Arduino to get


ready to exchange messages with the Serial Monitor at a data rate of 9600 bits per second. 
That’s 9600 binary ones or zeros per second, and is commonly called a baud rate

pinMode()

[Digital I/O]

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.

digitalWrite()

[Digital I/O]

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. See the Digital Pins tutorial for more information.

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.

Serial.available()

Description

Get the number of bytes (characters) available for reading from the
serial port. This is data that’s already arrived and stored in the serial
receive buffer (which holds 64 bytes).

Serial.available() inherits from the Stream utility class.


Syntax

Serial.available()

Parameters

Serial: serial port object. See the list of available serial ports for each
board on the Serial main page

Serial.read()

Description

Reads incoming serial data.

Serial.read() inherits from the Stream utility class.

Syntax

Serial.read()

Parameters

Serial: serial port object. See the list of available serial ports for each
board on the Serial main page .

analogWrite()

[Analog I/O]

Description
Writes an analog value (PWM wave) to a pin. Can be used to light a LED
at varying brightnesses or drive a motor at various speeds. After a call
to analogWrite(), the pin will generate a steady rectangular wave of the
specified duty cycle until the next call to analogWrite() (or a call to
digitalRead() or digitalWrite()) on the same pin.

BOARD PWM PINS PWM FREQUENCY

490 Hz (pins 5 and 6: 980


Uno, Nano, Mini 3, 5, 6, 9, 10, 11
Hz)
490 Hz (pins 4 and 13: 980
Mega 2 - 13, 44 - 46
Hz)
Leonardo, Micro, 3, 5, 6, 9, 10, 11, 490 Hz (pins 3 and 11: 980
Yún 13 Hz)

Uno WiFi Rev.2 3, 5, 6, 9, 10 976 Hz

0 - 8, 10, A3 (18),
MKR boards * 732 Hz
A4 (19)
0 - 8, 10, 11, A3
MKR1000 WiFi * 732 Hz
(18), A4 (19)
3 - 13, A0 (14), A1
Zero * 732 Hz
(15)

Due ** 2-13 1000 Hz

pins 3 and 9: 490 Hz, pins 5


101 3, 5, 6, 9
and 6: 980 Hz

* In addition to PWM capabilities on the pins noted above, the MKR and
Zero boards have true analog output when using analogWrite() on the
DAC0 (A0) pin.
** In addition to PWM capabilities on the pins noted above, the Due has
true analog output when using analogWrite() on pins DAC0 and DAC1.

You do not need to call pinMode() to set the pin as an output before
calling analogWrite(). The analogWrite function has nothing to do with
the analog pins or the analogRead function.
Syntax

analogWrite(pin, value)

Parameters

pin: the Arduino pin to write to. Allowed data types: int.
value: the duty cycle: between 0 (always off) and 255 (always on).
Allowed data types: int.

analogWrite()

[Analog I/O]

Description

Writes an analog value (PWM wave) to a pin. Can be used to light a LED
at varying brightnesses or drive a motor at various speeds. After a call
to analogWrite(), the pin will generate a steady rectangular wave of the
specified duty cycle until the next call to analogWrite() (or a call to
digitalRead() or digitalWrite()) on the same pin.

BOARD PWM PINS PWM FREQUENCY

490 Hz (pins 5 and 6: 980


Uno, Nano, Mini 3, 5, 6, 9, 10, 11
Hz)
490 Hz (pins 4 and 13: 980
Mega 2 - 13, 44 - 46
Hz)
Leonardo, Micro, 3, 5, 6, 9, 10, 11, 490 Hz (pins 3 and 11: 980
Yún 13 Hz)

Uno WiFi Rev.2 3, 5, 6, 9, 10 976 Hz

0 - 8, 10, A3 (18),
MKR boards * 732 Hz
A4 (19)

MKR1000 WiFi * 0 - 8, 10, 11, A3 732 Hz


BOARD PWM PINS PWM FREQUENCY

(18), A4 (19)
3 - 13, A0 (14), A1
Zero * 732 Hz
(15)

Due ** 2-13 1000 Hz

pins 3 and 9: 490 Hz, pins 5


101 3, 5, 6, 9
and 6: 980 Hz

* In addition to PWM capabilities on the pins noted above, the MKR and
Zero boards have true analog output when using analogWrite() on the
DAC0 (A0) pin.
** In addition to PWM capabilities on the pins noted above, the Due has
true analog output when using analogWrite() on pins DAC0 and DAC1.

You do not need to call pinMode() to set the pin as an output before
calling analogWrite(). The analogWrite function has nothing to do with
the analog pins or the analogRead function.

Syntax

analogWrite(pin, value)

Parameters

pin: the Arduino pin to write to. Allowed data types: int.
value: the duty cycle: between 0 (always off) and 255 (always on).
Allowed data types: int

Serial.println()

Description
Prints data to the serial port as human-readable ASCII text followed by
a carriage return character (ASCII 13, or '\r') and a newline character
(ASCII 10, or '\n'). This command takes the same forms as
Serial.print() .

Syntax

Serial.println(val)
Serial.println(val, format)

Parameters

Serial: serial port object. See the list of available serial ports for each
board on the Serial main page .
val: the value to print. Allowed data types: any data type.
format: specifies the number base (for integral data types) or number
of decimal places (for floating point types).

You might also like