0% found this document useful (0 votes)
59 views9 pages

San Sebastian College

The document summarizes an experiment using an Arduino microcontroller board to control LEDs. It describes connecting an LED and resistor to the Arduino board and writing code to: 1) Turn the LED on and off with a 500ms delay, 2) Continuously toggle the LED with a 1 second delay, and 3) Gradually decrease the delay from 1 second to 0 seconds using if/else statements and while loops to control the blinking rate of the LED. The conclusion states that the basic Arduino programming was simple to learn and allowed controlling tasks through digital input/output pins.

Uploaded by

Fritz Fatiga
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)
59 views9 pages

San Sebastian College

The document summarizes an experiment using an Arduino microcontroller board to control LEDs. It describes connecting an LED and resistor to the Arduino board and writing code to: 1) Turn the LED on and off with a 500ms delay, 2) Continuously toggle the LED with a 1 second delay, and 3) Gradually decrease the delay from 1 second to 0 seconds using if/else statements and while loops to control the blinking rate of the LED. The conclusion states that the basic Arduino programming was simple to learn and allowed controlling tasks through digital input/output pins.

Uploaded by

Fritz Fatiga
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/ 9

San Sebastian College-Recoletos de Cavite, Inc.

Cavite City

College of Engineering, Computer Studies & Technology

ECE4 SATURDAY 5:00-8:00 PM ECELAB


Section Day Time Room

COE19LAB: Microprocessor System Laboratory

Experiment No. 1
“INTRODUCTION TO ARDUINO “

November 18, 2017 November 25, 2017


Date Performed Date Submitted

Remarks Grade

Fatiga, Fritz Joseph D.


Group 1

Engr. Jerric T. Collera


Instructor
Objectives

1. To be familiarized in Arduino Microcontroller: Parts and Functions, Software


Environment

2. To be able to construct and execute simple program controlling the LEDs.


DISCUSSION
Our first activities on Arduino as an introduction are programming a Led
functions. The first part is connection +5v and GND of the Arduino into the Breadboard,
on the breadboard, we plugged a LED and a resistor which is connected to the wires
connected to the Arduino. Then we connect a wire from pin 13 on Arduino board into
the GND of the Breadboard, which will allow the Arduino to switch ON and OFF the Led,
lastly we program different functions for the LED.

On the first part, we simply program the LED’s switching time, it can also be
observed that the switching time of the LED on the breadboard and the LED on the
Arduino functions the same.

The Code used:

const int kPinLed = 13;

void setup() {

pinMode(kPinLed, OUTPUT);

void loop() {

digitalWrite(kPinLed, HIGH);

delay(500);

digitalWrite(kPinLed, LOW);

delay(500);

}
On the second part, we programmed the Led’s constant switching functions,
which is programmed on the Void loop.

The Code used:

const int kPinLed = 13;

void setup() {

pinMode(kPinLed, OUTPUT);

int delayTime=1000;

void loop() {

digitalWrite(kPinLed, HIGH);

delay(delayTime);

digitalWrite(kPinLed, LOW);

delay(delayTime);

}
On the third part, we programmed the Led’s switching delay time with a value of
1000mS , also we set it to progressively fast its switching which is encoded ; delay
time=delay time -100, thus increasing the delay time each loop. The programmed Led’s
switching will eventually reach 0 delay time, which will steadily have a constant
switching value, that’s why we programmed an If statement, which will reset the delay
time back to 1000ms whenever it reaches a delay time of 0s.

The Code used:

const int kPinLed = 13;

void setup() {

pinMode(kPinLed, OUTPUT);

int delayTime=1000;

void loop() {

delayTime = delayTime - 100;

if (delayTime <= 0){

delayTime =1000;

digitalWrite(kPinLed, HIGH);

delay(delayTime);

digitalWrite(kPinLed, LOW);

delay(delayTime);

}
The fourth activity is to provide a program whenever the last program didn’t
function, we added an else statement, which will rule over the above program, the else
statement acts as a backup program.

The code used:

const int kPinLed = 13;

void setup() {

pinMode(kPinLed, OUTPUT);

int delayTime=1000;

void loop() {

delayTime = delayTime - 100;

if (delayTime <= 0){

delayTime =1000;

else{

delayTime = delayTime - 100;

digitalWrite(kPinLed, HIGH);

delay(delayTime);

digitalWrite(kPinLed, LOW);

delay(delayTime);

}
Lastly, we simultaneously program two “while” statements, those to functions
acts alternately, in above program, whenever a the delay time is above 0s, the delay
time decreased -100ms, until it reaches 0, end when it reaches 0s , a delay time of
1000ms will be added, and so it will cycle back to the 1000ms delay time.

The code used:

const int kPinLed = 13;

void setup() {

pinMode(kPinLed, OUTPUT);

int delayTime=1000;

void loop() {

while(delayTime > 0){

digitalWrite(kPinLed, HIGH);

delay(delayTime);

digitalWrite(kPinLed, LOW);

delay(delayTime);

delayTime = delayTime - 100;

while (delayTime < 1000){

delayTime = delayTime + 100;

digitalWrite(kPinLed, HIGH);

delay(delayTime);

digitalWrite(kPinLed, LOW);

delay(delayTime);

}
CONCLUSION

On this activity, we have learned the basic of programming of the Arduino board,
which is overly simple, the program codes used is easy to memorize. As a brief
summary of the activity, the pinMode command sets the LED pin to be an output. The
first digitalWrite command says to set pin 13 of the Arduino to HIGH, or +5 volts. This
sends current from the pin, through the resistor, through the LED (which lights it) and to
ground. The delay(1000) command waits for 1000 msec. The second digitalWrite
command sets pin 13 to LOW or 0 V stopping the current thereby turning the LED off.
Code within the brackets defining the loop() function is repeated forever, which is why
the LED blinks. We have learned the capabilities of the Arduino to do multiple tasks
given a simple switching function of a Led.
CIRCUIT DIAGRAM

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy