Membuat counting down dengan Arduino

Halo teman – teman semua. Lama ya kita tidak berjumpa. Wis suwe cah ora ngArduino, hehe.. Ini tadi ad aide bikin aplikasi arduino. Sederhana sih, bikin counter hitung mundur. Tampilannya 7 segmen 4 digit memakai Arduino UNO.
Rangkaian counter Arduino seperti gambar di bawah :

Rangkaian counter Arduino

Hampir semua kaki Arduino terpakai. Pin 2 sampai pin 13 untuk koneksi ke segment a,b – h dari seven segment serta kaki basis transistor.
Program counter Arduino :

99 proyek arduino

int nilai,i;
byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 },  // = 0
                                 { 1,0,0,1,1,1,1 },  // = 1
                                 { 0,0,1,0,0,1,0 },  // = 2
                                 { 0,0,0,0,1,1,0 },  // = 3
                                 { 1,0,0,1,1,0,0 },  // = 4
                                 { 0,1,0,0,1,0,0 },  // = 5
                                 { 0,1,0,0,0,0,0 },  // = 6
                                 { 0,0,0,1,1,1,1 },  // = 7
                                 { 0,0,0,0,0,0,0 },  // = 8
                                 { 0,0,0,0,1,0,0 }   // = 9
                               };

void setup() {               
  pinMode(2, OUTPUT);  
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);  
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(9,HIGH);
  nilai=9999;
}
   
void sevenSegWrite(byte segment) {
  byte pin = 2;
  for (byte segCount = 0; segCount < 7; ++segCount) {
    digitalWrite(pin, seven_seg_digits[segment][segCount]);
    ++pin;
  }
}

void loop() {
  nilai–;
  for(i=0;i<50;i++){
      digitalWrite(10,LOW);
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
      digitalWrite(13,HIGH);
      sevenSegWrite(nilai/1000);
      delay(5);
      digitalWrite(10,HIGH);
      digitalWrite(11,LOW);
       digitalWrite(12,HIGH);
      digitalWrite(13,HIGH);
      sevenSegWrite(nilai%1000/100);
      delay(5);
      digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
      digitalWrite(12,LOW);
      digitalWrite(13,HIGH);
      sevenSegWrite(nilai%1000%100/10);
      delay(5);
      digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
      digitalWrite(13,LOW);
      sevenSegWrite(nilai%1000%100%10);
      delay(5);
  }
  if(nilai==0) while(1);  
}

Ok, upload saja dan hasiolnya jreng  jreng  jreng …

Counting down Arduino

Sederhana dan mudah bukan ? Silakan dicoba, dapat juga memakai Arduino tipe lain seperti Arduino mega.
Met ngArduino

Baner MM Ardu materi

This entry was posted in Arduino and tagged , , , , , , , . Bookmark the permalink.

4 Responses to Membuat counting down dengan Arduino

  1. Hernawan Praboow says:

    mas program nya error di nilai-;

    notice error nya stray ‘/’ in program

Leave a Reply