Kamis, 02 Februari 2017

LAPORAN 7

LAPORAN TEKNIK MEKATRONIKA SMK LEONARDO KLATEN
COUNTER UP & COUNTER DOWN

I. TUJUAN
  1. Siswa dapat mengetahui mengenai counter up & counter down,
  2. Siswa dapat membuat rangkaian counter up & counter down,
  3. Siswa dapat memahami mengenai counter up & counter down.
II. ALAT DAN BAHAN
  1. Komputer (PC)
  2. Program arduino
  3. Arduino uno
  4. protoboard
  5. 7 segment
  6. Resistor 10k (2)
  7. Resistor 330
  8. Push button (2)
  9. kabel jumper
III. DESKRIPSI TUGAS
  1. Membuat suatu rangkaian yang menerapkan sistem counter up dan counter down.
IV. LANGKAH KERJA
  1. Mencari rangkaian yang akan dibuat,
  2. Merangkai rangkaian counter up dan counter down yang didapat dengan benar,
  3. Membuat program di aplikasi arduino
Program :

int A=2;
int B=3;
int C=4;
int D=6;
int X=5;
int E=7;
int F=8;]
int G=9;
int tb1=13;
int tb2=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);
        digitalWrite(X ,HIGH);
        }
          void loop() 
          {
              buttonUpState =digitalRead(tb1);
              buttonDownState =digitalRead(tb2);
              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;
                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                                                 4. Verify sketch program tersebut untuk memastikan bahwa program tersebut benar,
                                                                                                                                                                                                                                                                                 5. Jika sudah benar, Upload program tersebut kedalam arduino uno. Jangan lupa mengatur board dan port di aplikasi arduino.

                                                                                                                                                                                                                                                                            V. HASIL KERJA
                                                                                                                                                                                                                                                                            menyusul

                                                                                                                                                                                                                                                                            VI. KESELAMATAN KERJA
                                                                                                                                                                                                                                                                            1. Menggunakan alat dengan baik,
                                                                                                                                                                                                                                                                            2. Mengerjakan dengan serius
                                                                                                                                                                                                                                                                            3. Menggunakan wearpack dengan lengkap
                                                                                                                                                                                                                                                                            VII. KESIMPULAN
                                                                                                                                                                                                                                                                            Pada praktek kali ini siswa dapat mengetahui,memahami dan merangkai rangkaian mengenai counter up dan counter down dengan benar.


                                                                                                                                                                                                                                                                                                                                                                               Klaten,2 Februari 2017  
                                                                                                                                                                                                                                                                                     Guru Pembimbing                                                                       peserta didik 
                                                                                                                                                                                                                                                                                             TTD                                                                                        TTD
                                                                                                                                                                                                                                                                                 Y. Prasetya Adi Nugroho, S.T                                                     Mohan Alfredo Y.A













                                                                                                                                                                                                                                                                            Tidak ada komentar:

                                                                                                                                                                                                                                                                            Posting Komentar