LAPORAN PRAKTEK MEKATRONIKA
SMK PL LEONARDO KLATEN
COUNTER UP DAN COUNTER DOWN
I. TUJUAN
- Siswa dapat mengetahui tentang Counter Up dan Counter Down.
- Siswa dapat memahami tentang rangkaian Counter Up dan Counter Down.
- Siswa dapat merangkai rangkaian Counter Up dan Counter Down.
II. ALAT DAN BAHAN
- Komputer (PC)
- Arduino UNO
- Program
- Seven Segment
- Kabel USB
- Kabel Jumper
- Push Button (2 buah)
- Resistor 330 (3 buah)
- Protoboard
- Membuat rangakaian seven segment memakai 2 push button dengan memakai Counter Up dan Counter Down.
IV. HASIL KERJA
- HASIL PROGRAM CODING
int a=2;
int b=3;
int c=4;
int d=6;
int dp=5;
int e=7;
int f=8;
int g=9;
int btn1=13;
int btn2=12;
int counter=0;
int buttonUpState=0;
int lastButtonUpState=0;
int buttonDownState=0;
int lastButtonDownState=0;
void setup()
{
Serial.begin(9600);
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
pinMode(g,OUTPUT);
pinMode(dp,OUTPUT);
digitalWrite(dp,HIGH);
}
void loop()
{
buttonUpState=digitalRead(btn1);
buttonDownState=digitalRead(btn2);
if(buttonUpState!=lastButtonUpState)
{
if(buttonUpState==HIGH)
{
if(counter==9)
{
counter=-1;
}
counter++;
Serial.println(counter);
changeNumber(counter);
delay(300);
}
else
{
Serial.println("OFF");
}
delay(50);
}
if(buttonDownState!=lastButtonDownState)
{
if(buttonDownState==HIGH)
{
if(counter == 0)
{
counter = 10;
}
counter--;
Serial.println(counter);
changeNumber(counter);
delay(300);
}
else
{
Serial.println("OFF");
}
delay(50);
}
changeNumber(counter);
}
void changeNumber(int buttonPress)
{
switch (buttonPress)
{
//number 0
case 0:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
break;
//number 1
case 1:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
//number 2
case 2:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
break;
//number 3
case 3:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
break;
//number 4
case 4:
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
//number 5
case 5:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
//number 6
case 6:
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
//number 7
case 7:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
break;
//number 8
case 8:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
//number 9
case 9:
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
break;
}
}
- VIDEO HASIL RANGKAIAN SEVEN SEGMENT
- GAMBAR HASIL KERJA
V. LANGKAH KERJA
- Menyiapkan alat dan bahan yang dibutuhkan
- Merangkai rangkaian seven segment di protoboard
- Membuat Program Coding di software arduino
- Lalu sambungkan arduino dengan Komputer
- Kemudian save program
- Apabila rangkaian dan program benar maka apabila tombol ditekan akan berjalan sesuai program
VI. KESELAMATAN KERJA
- Memakai Workpack
- Memakai topi dan sepatu
- Fokus dan teliti
- Tidak membawa makanan dan minuman dalam ruang praktek
- Menaati semua peraturanyang telah dibuat sebelumnya
VII. KESIMPULAN
Dalam kegiatan praktek kali ini siswa dapat memahami tentang konsep Counter Up dan Counter Down serta dapat mengaplikasikannya kedalam rangkaian Seven Segment yang memakai 2 push button.
KLATEN, 08 FEBRUARI 2017
Mengetahui,
Pembimbing Penulis
(Y.Prasetya Adi Nugraha,S.Pd) (Tria Agustini)
Tidak ada komentar:
Posting Komentar