Buka Senin - Jumat jam 08.30 s/d jam 16.30 , Sabtu Jam 8.30 s/d jam 13.00 , Minggu tutup
  • Selamat Datang di Indomaker ❯ Silahkan pesan produk sesuai kebutuhan anda, kami siap melayani.
  • Selamat Datang di Indomaker ❯ Silahkan pesan produk sesuai kebutuhan anda, kami siap melayani.
Beranda » Blog » Mencoba 7 Segment 4 Digit pada Arduino

Mencoba 7 Segment 4 Digit pada Arduino

Diposting pada 3 December 2019 oleh farhan / Dilihat: 1.114 kali / Kategori:

 

Sesuai judulnya kali ini kita akan mencoba 7 segment 4 digit pada Arduino. Dengan 4 digit ini berarti terdapat 4 kaki yang dijadikan sebagai commonya. Dibawah ini terdapat konfigurasi kaki-kaki pada 4 digit 7 segment yang ditandai oleh D1, D2, D3, dan D4.

Untuk menggunakannya berikut beberapa komponen yang digunakan :

  • Arduino Uno R3, BELI
  • 7 segment 4 digit, BELI
  • Kabel jumper secukupnya, BELI

Rangkaian

keterangan :

  • digit1 to Resistor1
  • digit2 to Resistor2
  • digit3 to Resistor3
  • digit4 to Resistor4
  • SegmentA to digitalPin 2
  • SegmentB to digitalPin 3
  • SegmentC to digitalPin 4
  • SegmentD to digitalPin 5
  • SegmentDecimalPoint to digitalPin 6
  • Resistor1 to digitalPin 7
  • Resistor1 to digitalPin 8
  • Resistor1 to digitalPin 9
  • Resistor1 to digitalPin 10
  • SegmentE to digitalPin 11
  • SegmentF to digitalPin 12
  • SegmentG to digitalPin 13

Sketch Program

#include <SevSeg.h>

int pinA = 2;int pinB = 3;int pinC = 4;int pinD = 5;
int pinE = 11;int pinF = 12;int pinG = 13;
int pinDP = 6;int D1 = 7;int D2 = 8;int D3 = 9; int D4 = 10;

void setup() {//set all segments & digits as outputs
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D4, OUTPUT);
}

void loop() {
  
  digit1();zero();delay(500);
  digit2();one();delay(500);
  digit3();two();delay(500);
  digit4();three();delay(500);
  digit3();four();delay(500);
  digit2();five();delay(500);
  digit1();six();delay(500);
  digit2();seven();delay(500);
  digit3();eight();delay(500);
  digit4();nine();delay(500);
 
  all4Digits();
  allNumbers();

}


//functions representing numbers 0-9
void zero(){
digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
digitalWrite(pinE, LOW);
digitalWrite(pinF, LOW);
digitalWrite(pinG, HIGH);
  }

  void one(){
digitalWrite(pinA, HIGH);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, HIGH);
digitalWrite(pinG, HIGH);
}

void two(){
  digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, HIGH);
digitalWrite(pinD, LOW);
digitalWrite(pinE, LOW);
digitalWrite(pinF, HIGH);
digitalWrite(pinG, LOW);
  }
  
  void three(){
    digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, HIGH);
digitalWrite(pinG, LOW);
    }
    
  void four(){
    digitalWrite(pinA, HIGH);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, LOW);
digitalWrite(pinG, LOW);
    }
    
  void five(){
    digitalWrite(pinA, LOW);
digitalWrite(pinB, HIGH);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, LOW);
digitalWrite(pinG, LOW);
    }
    
  void six(){
    digitalWrite(pinA, LOW);
digitalWrite(pinB, HIGH);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
digitalWrite(pinE, LOW);
digitalWrite(pinF, LOW);
digitalWrite(pinG, LOW);
    }
    
  void seven(){
    digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, HIGH);
digitalWrite(pinG, HIGH);
    }
    
  void eight(){
    digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
digitalWrite(pinE, LOW);
digitalWrite(pinF, LOW);
digitalWrite(pinG, LOW);
    }
    
  void nine(){
    digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, HIGH);
digitalWrite(pinE, HIGH);
digitalWrite(pinF, LOW);
digitalWrite(pinG, LOW);
    }

    void allNumbers(){
      one();delay(500);
two();delay(500);
three();delay(500);
four();delay(500);
five();delay(500);
six();delay(500);
seven();delay(500);
eight();delay(500);
nine();delay(500);
      }

  void turnOffAllSegments(){
          digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
digitalWrite(pinE, LOW);
digitalWrite(pinF, LOW);
digitalWrite(pinG, LOW);
          }


    //functions to select individual digits on the display
    void digit1(){
      digitalWrite(D1, HIGH);
digitalWrite(D2, LOW);
digitalWrite(D3, LOW);
digitalWrite(D4, LOW);
      }
      
    void digit2(){
      digitalWrite(D1, LOW);
digitalWrite(D2, HIGH);
digitalWrite(D3, LOW);
digitalWrite(D4, LOW);
      }
      
    void digit3(){
      digitalWrite(D1, LOW);
digitalWrite(D2, LOW);
digitalWrite(D3, HIGH);
digitalWrite(D4, LOW);
      }
      
    void digit4(){
      digitalWrite(D1, LOW);
digitalWrite(D2, LOW);
digitalWrite(D3, LOW);
digitalWrite(D4, HIGH);
      }

      void all4Digits(){
        digitalWrite(D1, HIGH);
digitalWrite(D2, HIGH);
digitalWrite(D3, HIGH);
digitalWrite(D4, HIGH);
        }

Tinggal upload saja ke Arduino IDE sketch program di atas, selamat mencoba.

Bagikan ke

Mencoba 7 Segment 4 Digit pada Arduino

Saat ini belum tersedia komentar.

Silahkan tulis komentar Anda

Mencoba 7 Segment 4 Digit pada Arduino

Produk yang sangat tepat, pilihan bagus..!

Berhasil ditambahkan ke keranjang belanja
Lanjut Belanja
Checkout
Produk Quick Order

Pemesanan dapat langsung menghubungi kontak dibawah: