Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

LAPORAN PRAKTIKUM

SISTEM MIKROPROSESOR DASAR


RUNNING LED MENGGUNAKAN ARDUINO UNO

Disusun oleh :

Kelompok 5

Nama Anggota : 1. Intan Ayu Nurul Dwi Oktaviani (2303321042)

2. Rangga Aulia Rusli (2303321083)

3. Wan Dzuljalaali Wal Ikraam (2303321091)

Kelas : EC-2D

Dosen Pengajar : Hariyanto, S.Pd., M.T.

LABORATORIUM 1 GEDUNG C

PRODI ELEKTRONIKA INDUSTRI

JURUSAN TEKNIK ELEKTRO

POLITEKNIK NEGERI JAKARTA

2024
A. Program

1) Running LED Manual


// the setup function runs once when you press reset or power the
board
void setup()
{
pinMode(0, OUTPUT); // initialize digital pin 0 as an output.
pinMode(1, OUTPUT); // initialize digital pin 1 as an output.
pinMode(2, OUTPUT); // initialize digital pin 2 as an output.
pinMode(3, OUTPUT); // initialize digital pin 3 as an output.
pinMode(4, OUTPUT); // initialize digital pin 4 as an output.
pinMode(5, OUTPUT); // initialize digital pin 5 as an output.
pinMode(6, OUTPUT); // initialize digital pin 6 as an output.
pinMode(7, OUTPUT); // initialize digital pin 7 as an output.
}
// the loop function runs over and over again forever
void loop()
{
digitalWrite(0, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, HIGH);// turn the LED on (HIGH is the voltage level)
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 0,5 second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
digitalWrite(7, HIGH);// turn the LED on (HIGH is the voltage level)
delay(500); // wait for 0,5 second
}

2) Running LED Menggunakan For-Loop


const int ledPins[]= {6,7,8,9,10,11,12,13};//mengatur pin pin yang
ada pada digital pin
const int numLeds = 8;//mendefinisikan ada berapa jumlah led

void setup() {
// put your setup code here, to run once:
for (int i= 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
}
void loop() {
// put your main code here, to run repeatedly:
for (int i= 0; i < numLeds; i++) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
for (int i= numLeds - 1; i >= 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
}

B. Hasil

You might also like