0% found this document useful (0 votes)
40 views6 pages

Pengembangan Aplikasi Platform Khusus (PAPK) Laporan Tugas Praktikum 1 Arduino

The document reports on modifications made to Arduino programs to control LEDs using delays and button inputs. It also explains the differences between Program 5 and Program 6 in how they use a potentiometer to control an LED. Program 5 uses a potentiometer to continuously adjust the LED brightness based on the voltage applied. Program 6 only has two states for the LED (on or off) depending on the potentiometer position.

Uploaded by

Helkia Pasaribu
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)
40 views6 pages

Pengembangan Aplikasi Platform Khusus (PAPK) Laporan Tugas Praktikum 1 Arduino

The document reports on modifications made to Arduino programs to control LEDs using delays and button inputs. It also explains the differences between Program 5 and Program 6 in how they use a potentiometer to control an LED. Program 5 uses a potentiometer to continuously adjust the LED brightness based on the voltage applied. Program 6 only has two states for the LED (on or off) depending on the potentiometer position.

Uploaded by

Helkia Pasaribu
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/ 6

Pengembangan Aplikasi Platform Khusus [PAPK]

Laporan Tugas Praktikum 1


ARDUINO

Oleh Kelompok 6:
Oktavi Silitonga (11S14004)
Romasi Sibarani (11S14005)
Helkia Pasaribu(11S14027)
Gideon Manurung (11S14046)
S1TI 2014

PROGRAM STUDI SARJANA TEKNIK INFORMATIKA


FAKULTAS TEKNIK INFORMATIKA DAN ELEKTRO
INSTITUT TEKNOLOGI DEL
2017

1. Modifikasi Program 1 dan Program 2


Source code :
Program 1 Program 2
Sebelum // Pin 13 has an LED connected on // Pin 11 12 13 has an LED
Dimodifikas most Arduino boards. connected on most Arduino
i // give it a name: boards.
int led = 13; // give it a name:
// the setup routine runs once when int led1 = 11;
you press reset: int led2 = 12;
void setup() { int led3 = 13;
Serial.begin(9600); // the setup routine runs once
Serial.println("Hello world!"); when you press reset:
// initialize the digital pin as an void setup() {
output. // initialize the digital pin as an
pinMode(led, OUTPUT); output.
} pinMode(led1, OUTPUT);
// the loop routine runs over and over pinMode(led2, OUTPUT);
again forever: pinMode(led3, OUTPUT);
void loop() { }
digitalWrite(led, HIGH);//turn the LED // the loop routine runs over and
on (HIGH is the voltage level) over again forever:
delay(1000); // wait for a second void loop() {
digitalWrite(led, LOW); // turn the LED digitalWrite(led1, HIGH);
off by making the voltage LOW delay(1000);
delay(1000); // wait for a second digitalWrite(led1, LOW);
} delay(1000);
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led2, LOW);
delay(1000);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led3, LOW);
delay(1000);
}
Sesudah // Pin 13 has an LED connected on // Pin 11 12 13 has an LED
Dimodifikas most Arduino boards. connected on most Arduino
i // give it a name: boards.
int led = 13; // give it a name:
// the setup routine runs once when int led1 = 11;
you press reset: int led2 = 12;
void setup() { int led3 = 13;
Serial.begin(9600); int led4 = 10;
Serial.println("Hello world!"); // the setup routine runs once
// initialize the digital pin as an when you press reset:
output. void setup() {
pinMode(led, OUTPUT); // initialize the digital pin as an
} output.
// the loop routine runs over and over pinMode(led1, OUTPUT);
again forever: pinMode(led2, OUTPUT);
void loop() { pinMode(led3, OUTPUT);
digitalWrite(led, HIGH);//turn the LED pinMode(led4, OUTPUT);
on (HIGH is the voltage level) }
delay(10000); // wait for a second // the loop routine runs over and
digitalWrite(led, LOW); // turn the LED over again forever:
off by making the voltage LOW void loop() {
delay(500); // wait for a second digitalWrite(led1, HIGH);
} delay(50);
digitalWrite(led1, LOW);
delay(0);
digitalWrite(led2, HIGH);
delay(50);
digitalWrite(led2, LOW);
delay(0);
digitalWrite(led3, HIGH);
delay(50);
digitalWrite(led3, LOW);
delay(0);
digitalWrite(led4, HIGH);
delay(50);
digitalWrite(led4, LOW);
delay(0);
}

Salah satu output hasil modifikasi: Menghasilkan lampu yang menyala bergantian
dengan delay(50).
2. Mengubah program 4 sehingga setiap kali tombol ditekan akan keluar Hello World

Program 4 sebelum Dimodifikasi Program 4 setelah Dimodifikasi


// Pin 13 has an LED and a push // Pin 13 has an LED and a push
button connected on Arduino boards. button connected on Arduino boards.
// give it a name: // give it a name:
int led = 13; int led = 13;
int buttonPin=2; int buttonPin=2;
int buttonState; int buttonState;
// the setup routine runs once when // the setup routine runs once when
you press reset: you press reset:
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
// initialize the digital pin as an // initialize the digital pin as an
output. output.
pinMode(led, OUTPUT); pinMode(led, OUTPUT);
// initialize the pushbutton as an // initialize the pushbutton as an
input. input.
pinMode(buttonPin, INPUT); pinMode(buttonPin, INPUT);
} }
// the loop routine runs over and over // the loop routine runs over and over
again forever: again forever:
void loop() { void loop() {
// Read the state of the pushbutton // Read the state of the pushbutton
value value
buttonState = buttonState =
digitalRead(buttonPin); digitalRead(buttonPin);
// check if the pushbutton is pressed // check if the pushbutton is pressed
// if it is, the buttonState is HIGH // if it is, the buttonState is HIGH
if (buttonState == LOW) { if (buttonState == LOW) {
// turn LED off // turn LED off
digitalWrite(led, LOW); digitalWrite(led, LOW);
} else{ } else{
// turn LED on // turn LED on
digitalWrite(led, HIGH); digitalWrite(led, HIGH);
} Serial.println("Hello world!");
} }
}
Output :
Lampu : Saat button ditekan, maka lampu akan menyala dan akan memprint
Hello World. Jika lampu tidak ditekan, maka lampu tetap padam dan tidak
memprint Hello World.

HelloWorld
3. Perbedaan program 5 dan Program 6 dengan menjelaskan cara kerja potensiometer
Jawab :
Cara kerja potensiometer :
Potensiometer ini bekerja seperti sebuah saklar yang berfungsi untuk mengubah
tegangan. Untuk lebih jelasnya, perbedaan penggunaan potensiometer dapat dilihat
pada penjelasan Program 5 dan Program 6.

Program 5 Program 6
Cara kerja potensiometer adalah Pada program 6 ini cara kerja
mengubah besar tegangan secara potensiometer ini simple. Karena hanya
continue, artinya lampu menyala terdiri dari 2 state yaitu antara 0 dan 1
berkedip-kedip dimana kecepatannya atau menyala dan padam. Dimana 0
berdasarkan tegangan yang diberikan diputar arah searah jarum jam yang
melalui potensio meter. Dimana pada membuat lampu padam, dan 1 diputar
program 5 ini lampu berkedip semakin berlawanan arah jarum jam, yang
cepat jika potensiometer diputar membuat lampu menyala.
berlawanan arah jarum jam dan akan
lebih lambat jika diputar berlawanan arah
jarum jam dan lampu akan padam jika
potensiometer diputar searah jarum jam
sampai mencapai titik akhir.

You might also like