Data Sheet

ARDUINO CODE
LESSON 6
| 31
The Serial.begin() open a serial
communication between the
MAKER-UNO and the computer. 9600 is
the baud rate of the comunication. The
serial monitor must use the same baud
rate to view the information.
The Serial.print() sends
information from
MAKER-UNO to the
connected computer. The
information will be in the
int Button = 2;
void setup()
{
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
}
void loop()
{
if (digitalRead(Button) == LOW)
{
Serial.print("Button is PRESS!");
}
else if (digitalRead(Button) == HIGH)
{
Serial.println("Button is NOT PRESS!");
}
}
RESULT
The Serial Monitor will print "Button is PRESS!" when the button is realesed and the Serial
Monitor will print "Button is NOT PRESS!" when the button is not pressed.