0% found this document useful (0 votes)
6 views1 page

Function DigitalRead

The document explains how to use the digitalRead() function to check voltage levels on a digital input pin in Arduino programming. It covers the use of if() and else statements for conditional comparisons, as well as the Serial monitor for reporting results from the microcontroller. Additionally, it describes the commands Serial.begin() and Serial.print() for establishing communication with a computer and sending information, respectively.

Uploaded by

Hamza Belgarouia
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)
6 views1 page

Function DigitalRead

The document explains how to use the digitalRead() function to check voltage levels on a digital input pin in Arduino programming. It covers the use of if() and else statements for conditional comparisons, as well as the Serial monitor for reporting results from the microcontroller. Additionally, it describes the commands Serial.begin() and Serial.print() for establishing communication with a computer and sending information, respectively.

Uploaded by

Hamza Belgarouia
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/ 1

Function digitalRead():

To check the voltage level on a digital input, you use the function digitalRead() that checks the
chosen pin for voltage. To know what pin to check, digitalRead() expects an argument.
Arguments are information that you pass to functions,
telling them how they should do their job. For example, digitalRead() needs one argument:
what pin to check. In your program, digitalRead() is going to check the state of.

If () statement:
An if() statement in programming compares two things, and determines whether
the comparison is true or false. Then it performs actions you tell it to do. When comparing two
things in programming, you use two equal signs ==. If you use only one sign, you will be seting a
value instead of comparing it.

Else statement:
The if() statement has an optional else component that allows for something to happen if the
original condition is not met.

Serial monitor:
The Arduino IDE comes with a tool called the serial monitor that enables you to
report back results from the microcontroller. Using the serial monitor, you can get
information about the status of sensors, and get an idea about what is happening
in your circuit and code as it runs.

Command Serial.begin():
In the setup you’re going to use a new command, Serial. begin(). This opens up a connection
between the Arduino and the computer, so you can see the values from the analog input on
your computer screen. The argument 9600 is the speed at which the Arduino will communicate,
9600 bits per second. You will use the Arduino IDE’s serial monitor to view the information you
choose to send from your microcontroller. When you open the IDE’s serial monitor verify that
the baud rate is 9600.

Function Serial.print():
The function Serial.print() sends information from the Arduino to a connected computer. You
can see this information in your serial monitor. If you give Serial.print() an argument in
quotation marks, it will print out the text you typed.
If you give it a variable as an argument, it will print out the value of that variable.

You might also like