You are on page 1of 7

Don Honorio Ventura State University

College of Engineering and Architecture


Electronics Engineering Department
Villa de Bacolor, Pampanga

NAME OF MEMBERS:

GROUP NUMBER: DATE PERFORMED:


COURSE CODE: DIGIELECS 2 Lab DATE SUBMITTED:
COURSE TITLE: Digital Electronics 2 (Laboratory) YEAR AND SECTION:
LAB. INSTRUCTOR: Engr. Enmar T. Tuazon GRADE:

LABORATORY ACTIVITY NO. 1


INTRODUCTION TO ARDUINO PROGRAMMING

OBJECTIVES
1. TO FAMILIARIZE YOURSELVES TO THE ARDUINO ENVIRONMENT BOTH ON THE
HARDWARE AND SOFTWARE INTERACTION
2. TO LEARN HOW TO INITIALIZE AND SETUP INPUT AND OUTPUT PINS
3. TO LEARN HOW TO USE VOID LOOP, DIGITALWRITE AND DELAY COMMANDS

DISCUSSIONS

setup()
Description
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start
using libraries, etc. The setup() function will only run once, after each powerup or reset of the
Arduino board.

loop()
Description
After creating a setup() function, which initializes and sets the initial values, the loop() function
does precisely what its name suggests, and loops consecutively, allowing your program to
change and respond. Use it to actively control the Arduino board.

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.

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)

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. 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)

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)

Example Code
The code makes the digital pin 13 an OUTPUT and toggles it by alternating between HIGH and
LOW at one second pace.

void setup() {
pinMode(13, OUTPUT); // sets the digital pin 13 as output
}

void loop() {
digitalWrite(13, HIGH); // sets the digital pin 13 on
delay(1000); // waits for a second
digitalWrite(13, LOW); // sets the digital pin 13 off
delay(1000); // waits for a second
}
MATERIALS
ARDUINO KIT RESISTORS
BREADBOARD CONNECTING WIRES
LED’S

PROCEDURE

- Use at least 3 LED’s and 3 Digital pins, and make your own sequence. The more the
better.

PHOTODOCUMENTATIONS:
CODE:
Individual Report
Name: ________________________ CYS: ____________ Date: _______________ G#: __

Introduction (What is the activity about?)

Discussion (What are your observations, the challenges you encountered and how did you solve
them?)

Conclusion (What have you learned?)


Individual Report
Name: ________________________ CYS: ____________ Date: _______________ G#: __

Introduction (What is the activity about?)

Discussion (What are your observations, the challenges you encountered and how did you solve
them?)

Conclusion (What have you learned?)


Individual Report
Name: ________________________ CYS: ____________ Date: _______________ G#: __

Introduction (What is the activity about?)

Discussion (What are your observations, the challenges you encountered and how did you solve
them?)

Conclusion (What have you learned?)

You might also like