Goodemorgen fellas!

Di pagi hari yang super dingin ini saya ingin cerita lagi mengenai proyek kedua saya pada mata kuliah Interaksi Manusia Komputer dan  Antarmuka, yaitu 7 segment display with push-button. Masih bersama saya Nindy dan kedua teman saya yang caleuy Atika dan Rizaldy.

s__2252830
Gambar 1. Atika – Rizaldy – Nindy

Okay, jadi pada tugas kali ini yang perlu kami lakukan cukup simple, yaitu menampilkan angka 0-9 pada seven segment dengan memanfaatkan push-button.

Alat dan Bahan

dsc04072
Gambar 2. Alat dan Bahan
  • 1 set Arduino UNO
  • 1 buah BreadBoard
  • 1 buah 7 Segment
  • 1 buah Push Buttons
  • 3 buah resistors 220 ohm
  • 15 buah kabel jumper (Male to male)

How to make it?

Rangkai komponen seperti skema pada Gambar 2:

  • Breadboard plus ke pin Arduino 5V
  • Breadboard minus ke pin Arduino GND
  • Pin 8 dan pin 3 7-Segment ke breadboard plus melalui resistor
  • Pin 1 7-Segment ke pin 6 Arduino
  • Pin 2 7-Segment ke pin 5 Arduino
  • Pin 4 7-Segment ke pin 4 Arduino
  • Pin 5 7-Segment ke pin 7 Arduino
  • Pin 6 7-Segment ke pin 2 Arduino
  • Pin 7 7-Segment ke pin 3 Arduino
  • Pin 9 7-Segment ke pin 8 Arduino
  • Pin 10 7-Segment ke pin 9 Arduino
  • Salah satu sisi puIsh button ke breadboard plus
  • Sisi lain push-button ke GND breadboard dan ke pin 12

Skema

7segment

Tugas 2 - 7 Segment.png
Gambar 3. Skema Rangkaian

 

Source Code


//Inisialisasi Pin 7-Segment
int A = 3;
int B = 2;
int C = 4;
int D = 5;
int DP = 7;
int E = 6;
int F = 8;
int G = 9;

//Inisialisasi Pin Push button, state awal dan membuat counter
int switchUpPin = 13;
int counter = 0;
int buttonUpState = 0;
int lastButtonUpState = 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);

//Start with the decimal point off
 digitalWrite(DP ,HIGH);
}

void loop()
{
 //Getting the reads from the buttons
 buttonUpState = digitalRead(switchUpPin);

//Detecting button press and getting the button status
 //Do this for the button up
 if (buttonUpState != lastButtonUpState)
 {
 if (buttonUpState == HIGH)
 {
 //Reset the counter to -1
 if(counter == 9)
 {
 counter = -1;
 }
 //Increase the counter by 1
 counter++;
 //Print the counter to the console and calling the function
 Serial.println(counter);
 changeNumber(counter);
 //Delaying by 250 ms
 delay(250);
 }
 else
 {
 Serial.println("OFF");
 }
 //Delay to avoid button bouncing
 delay(50);
 }

 //Calling the function changeNumber with the arg counter
 changeNumber(counter);
}

//The function to display the numbers
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, HIGH);
 digitalWrite(E, HIGH);
 digitalWrite(F, LOW);
 digitalWrite(G, LOW);
 break;
 }
}

Sumber : www.instructables.com

Hasil Pengerjaan

0-9
Gambar 4. Hasil pengerjaan

Dokumentasi video bisa dilihat disini yaah

2nd Experiment : 7-Segment Loop . . #arduino #uno #7segment #numbers

A post shared by RNA (@rnateamid) on

Di proyek kali ini kami sudah mulai terbiasa dalam merangkai komponen (mulai me-recall ingatan semester 3) haha. Terdapat sedikit kesulitan dalam mengalokasikan sumber daya agar efektif dan efisien (berhubung breadboard yang kami punya kecil).

Okay sekian penjelasan proyek kedua kami. Semoga bermanfaat!

Dibuat oleh :

Rizaldy Al Kautsar (18214026)

Atika Rahmawati (18214044)

Nindy Aditya Dewi (18214052)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s