Mesin antrian 1 loket dengan tampilan seven segment 3 digit dan output suara antrian. Petugas loket menekan tombol NEXT untuk memanggil nomor antrian, secara bersamaan 7 segment menampilkan nomor antrian dan suara nomor antrian.
Terdapat 2 tombol, yang pertama adalah tombol NEXT yaitu tombol untuk memanggil nomor antrian berikutnya, sedangkan tombol yang ke-2 untuk mengulang panggilan tanpa menambah nomor antrian. Seven segment menampilkan urutan antrian. Suara dihasilkan dari IC ISD17xx, suara nomor antrian direkam pada IC tersebut kemudian Arduino mengakses alamat nomor suara menggunakan komunikasi SPI.
Kebutuhan Hardware
- Modul Seven segment 3 digit
- 2 Tombol push ON
- Modul ISD 17xx (yang kita gunakan ISD 17180)
- Speaker 0.5W 8Ohm
- Amplifier (jika suara kurang keras)
- Modul Arduino UNO
- Power supply +5 Volt
ISD 17180 | Source
Speaker | Source
Diagram Blok
Schematic
7-Segment CA Wiring | Source
Koneksi Arduino UNO dengan 7 segment
Koneksi Arduino UNO dengan Buttons
Koneksi Arduino UNO dengan
Source Code/Sketch
#include <ISD1700.h>
#define tbLoketNext A4
#define tbLoketR A5
//ISD1700 chip(10); // Initialize chipcorder with
// SS at Arduino's digital pin 10
int apc=0;
int vol=0; //volume 0=MAX, 7=min
int startAddr=0x10;
int endAddr =0x2DF;
char angka;
byte rat,pul,sat,Next;
byte f_noUrut,f_rat,f_pul;
word tunda;
word noAntri=0;
long lastButton = 0;
long delayAntiBouncing = 50;
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(){
apc = apc | vol; //D0, D1, D2
apc = apc | 0x50; // D4& D6 select MIC REC
apc = apc | 0x80; // D7 AUX ON, comment enable AUD
apc = apc | 0x100; // D8 SPK OFF, comment enable SPK
apc = apc | 0x800; // D11 EOM ON, comment disable EOM
for(char i=2; i<9; i++){
pinMode(i,OUTPUT);
}
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(tbLoketNext,INPUT);
pinMode(tbLoketR,INPUT);
digitalWrite(tbLoketNext,HIGH);
digitalWrite(tbLoketR,HIGH);
}
void loop(){
/******************
'*'ANTRIAN NOMOR
'1'SATU
'9'SEMBILAN
'A'SEPULUH
'B'SEBELAS
'C'BELAS
'D'PULUH
'E'RATUS
'F'SERATUS
*****************/
rat=noAntri/100;
pul=(noAntri%100)/10;
sat=(noAntri%100)%10;
tampil7Segment();
if (digitalRead(tbLoketNext)==0){
if ((millis() - lastButton) > delayAntiBouncing){
tunda=0;
noAntri++;
Next=1;
f_noUrut=0;
f_rat=0;
f_pul=0;
}
lastButton = millis();
}
else if(digitalRead(tbLoketR)==0){
if ((millis() - lastButton) > delayAntiBouncing){
tunda=0;
Next=1;
f_noUrut=0;
f_rat=0;
f_pul=0;
}
lastButton = millis();
}
if (Next==1){
if (f_noUrut==0) gotoISD_noUrut();
else if (f_noUrut==1 && f_rat==0)gotoISD_rat();
else if (f_rat==1 && f_pul==0)gotoISD_pul();
else if (f_pul==1)gotoISD_sat();
}
}
//=========================================
void gotoISD_noUrut(){
if(tunda==0 && f_noUrut==0){
angka='*';
data_ISD();
f_noUrut=1;
}
}
//=============================ratusan
void gotoISD_rat(){
//--------------200,300,400....dst
if (rat>1 && f_rat==0){
if (tunda==120){
angka=rat;
data_ISD();
}
else if (tunda==180){
angka='E';
data_ISD();
f_rat=1;
tunda=0;
}
}
//--------------100
else if(rat==1 && pul==0 && sat==0 && f_rat==0 && tunda==120){
angka='F';
data_ISD();
Next=0;
}
//--------------seratusan
else if(rat==1 && f_rat==0 && tunda==120){
angka='F';
data_ISD();
f_rat=1;
tunda=0;
}
//--------------ratusan=0
else if (rat==0 && f_rat==0 && tunda==120){
f_rat=1;
tunda=0;
}
}
//================================puluhan
void gotoISD_pul(){
//----------22 s/d 29, 32 s/d 39.....dst
if(pul>1 && sat>1 && f_pul==0){
if(tunda==60){
angka=pul;
data_ISD();
}
else if(tunda==120){
angka='D';
data_ISD();
f_pul=1;
tunda=0;
}
}
//--------------------12 s/d 19
else if(pul>0 && sat>1 && f_pul==0){
if(tunda==60){
angka=sat;
data_ISD();
}
else if(tunda==120){
angka='C';
data_ISD();
f_pul=1;
tunda=0;
}
}
//--------------sebelas
else if(pul==1 && sat==1 && f_pul==0 && tunda==60){
angka='B';
data_ISD();
f_pul=1;
tunda=0;
}
//--------------sepuluh
else if(pul==1 && f_pul==0 && tunda==60){
angka='A';
data_ISD();
f_pul=1;
tunda=0;
}
//--------------20,21,30,31,40,41....dst
else if(pul>1 && sat>=0 && f_pul==0){
if(tunda==60){
angka=pul;
data_ISD();
}
else if(tunda==120){
angka='D';
data_ISD();
f_pul=1;
tunda=0;
}
}
//----------101 s/d 109, 201 s/d 209...dst
else if(pul==0 && sat>0 && tunda==60){
angka=sat;
data_ISD();
Next=0;
}
}
//=================================satuan
void gotoISD_sat(){
//---------------1 s/d 9
if(sat>0 && pul!=1 && tunda==60){
angka=sat;
data_ISD();
Next=0;
}
}
//==============================data ISD
void data_ISD(){
switch(angka){
chip.pu();
case '*':
chip.pu();
startAddr=0x15;
endAddr =0x1E;
chip.set_play(startAddr,endAddr);
break;
case 1:
//------------SATU
chip.pu();
startAddr=0x21;
endAddr =0x24;
chip.set_play(startAddr,endAddr);
break;
case 2:
//-------------DUA
chip.pu();
startAddr=0x29;
endAddr =0x2C;
chip.set_play(startAddr,endAddr);
break;
case 3:
//-------------TIGA
chip.pu();
startAddr=0x30;
endAddr =0x33;
chip.set_play(startAddr,endAddr);
break;
case 4:
//------------EMPAT
chip.pu();
startAddr=0x38;
endAddr =0x3A;
chip.set_play(startAddr,endAddr);
break;
case 5:
//------------LIMA
chip.pu();
startAddr=0x3F;
endAddr =0x41;
chip.set_play(startAddr,endAddr);
break;
case 6:
//------------ENAM
chip.pu();
startAddr=0x46;
endAddr =0x49;
chip.set_play(startAddr,endAddr);
break;
case 7:
//------------TUJUH
chip.pu();
startAddr=0x4E;
endAddr =0x50;
chip.set_play(startAddr,endAddr);
break;
case 8:
//------------DELAPAN
chip.pu();
startAddr=0x55;
endAddr =0x58;
chip.set_play(startAddr,endAddr);
break;
case 9:
//------------SEMBILAN
chip.pu();
startAddr=0x5D;
endAddr =0x60;
chip.set_play(startAddr,endAddr);
break;
case 'A':
//------------SEPULUH
chip.pu();
startAddr=0x65;
endAddr =0x68;
chip.set_play(startAddr,endAddr);
break;
case'B':
//------------SEBELAS
chip.pu();
startAddr=0x6D;
endAddr =0x70;
chip.set_play(startAddr,endAddr);
break;
case'C':
//------------BELAS
chip.pu();
startAddr=0x75;
endAddr =0x78;
chip.set_play(startAddr,endAddr);
break;
case'D':
//------------PULUH
chip.pu();
startAddr=0x7C;
endAddr =0x80;
chip.set_play(startAddr,endAddr);
break;
case'E':
//------------RATUS
chip.pu();
startAddr=0x84;
endAddr =0x88;
chip.set_play(startAddr,endAddr);
break;
case'F':
//------------SERATUS
chip.pu();
startAddr=0x8D;
endAddr =0x90;
chip.set_play(startAddr,endAddr);
break;
}
}
void tampil7Segment(){
if(rat>0){
digitalWrite(A0,LOW); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
sevenSegWrite(rat);
delay(5);
}
if(pul>0 || rat>0){
digitalWrite(A0,HIGH); digitalWrite(A1,LOW);
digitalWrite(A2,HIGH);
sevenSegWrite(pul);
delay(5);
}
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,LOW);
sevenSegWrite(sat);
delay(5);
tunda++;
}
void sevenSegWrite(byte segment){
byte pin = 2;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}
#define tbLoketNext A4
#define tbLoketR A5
//ISD1700 chip(10); // Initialize chipcorder with
// SS at Arduino's digital pin 10
int apc=0;
int vol=0; //volume 0=MAX, 7=min
int startAddr=0x10;
int endAddr =0x2DF;
char angka;
byte rat,pul,sat,Next;
byte f_noUrut,f_rat,f_pul;
word tunda;
word noAntri=0;
long lastButton = 0;
long delayAntiBouncing = 50;
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(){
apc = apc | vol; //D0, D1, D2
apc = apc | 0x50; // D4& D6 select MIC REC
apc = apc | 0x80; // D7 AUX ON, comment enable AUD
apc = apc | 0x100; // D8 SPK OFF, comment enable SPK
apc = apc | 0x800; // D11 EOM ON, comment disable EOM
for(char i=2; i<9; i++){
pinMode(i,OUTPUT);
}
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(tbLoketNext,INPUT);
pinMode(tbLoketR,INPUT);
digitalWrite(tbLoketNext,HIGH);
digitalWrite(tbLoketR,HIGH);
}
void loop(){
/******************
'*'ANTRIAN NOMOR
'1'SATU
'9'SEMBILAN
'A'SEPULUH
'B'SEBELAS
'C'BELAS
'D'PULUH
'E'RATUS
'F'SERATUS
*****************/
rat=noAntri/100;
pul=(noAntri%100)/10;
sat=(noAntri%100)%10;
tampil7Segment();
if (digitalRead(tbLoketNext)==0){
if ((millis() - lastButton) > delayAntiBouncing){
tunda=0;
noAntri++;
Next=1;
f_noUrut=0;
f_rat=0;
f_pul=0;
}
lastButton = millis();
}
else if(digitalRead(tbLoketR)==0){
if ((millis() - lastButton) > delayAntiBouncing){
tunda=0;
Next=1;
f_noUrut=0;
f_rat=0;
f_pul=0;
}
lastButton = millis();
}
if (Next==1){
if (f_noUrut==0) gotoISD_noUrut();
else if (f_noUrut==1 && f_rat==0)gotoISD_rat();
else if (f_rat==1 && f_pul==0)gotoISD_pul();
else if (f_pul==1)gotoISD_sat();
}
}
//=========================================
void gotoISD_noUrut(){
if(tunda==0 && f_noUrut==0){
angka='*';
data_ISD();
f_noUrut=1;
}
}
//=============================ratusan
void gotoISD_rat(){
//--------------200,300,400....dst
if (rat>1 && f_rat==0){
if (tunda==120){
angka=rat;
data_ISD();
}
else if (tunda==180){
angka='E';
data_ISD();
f_rat=1;
tunda=0;
}
}
//--------------100
else if(rat==1 && pul==0 && sat==0 && f_rat==0 && tunda==120){
angka='F';
data_ISD();
Next=0;
}
//--------------seratusan
else if(rat==1 && f_rat==0 && tunda==120){
angka='F';
data_ISD();
f_rat=1;
tunda=0;
}
//--------------ratusan=0
else if (rat==0 && f_rat==0 && tunda==120){
f_rat=1;
tunda=0;
}
}
//================================puluhan
void gotoISD_pul(){
//----------22 s/d 29, 32 s/d 39.....dst
if(pul>1 && sat>1 && f_pul==0){
if(tunda==60){
angka=pul;
data_ISD();
}
else if(tunda==120){
angka='D';
data_ISD();
f_pul=1;
tunda=0;
}
}
//--------------------12 s/d 19
else if(pul>0 && sat>1 && f_pul==0){
if(tunda==60){
angka=sat;
data_ISD();
}
else if(tunda==120){
angka='C';
data_ISD();
f_pul=1;
tunda=0;
}
}
//--------------sebelas
else if(pul==1 && sat==1 && f_pul==0 && tunda==60){
angka='B';
data_ISD();
f_pul=1;
tunda=0;
}
//--------------sepuluh
else if(pul==1 && f_pul==0 && tunda==60){
angka='A';
data_ISD();
f_pul=1;
tunda=0;
}
//--------------20,21,30,31,40,41....dst
else if(pul>1 && sat>=0 && f_pul==0){
if(tunda==60){
angka=pul;
data_ISD();
}
else if(tunda==120){
angka='D';
data_ISD();
f_pul=1;
tunda=0;
}
}
//----------101 s/d 109, 201 s/d 209...dst
else if(pul==0 && sat>0 && tunda==60){
angka=sat;
data_ISD();
Next=0;
}
}
//=================================satuan
void gotoISD_sat(){
//---------------1 s/d 9
if(sat>0 && pul!=1 && tunda==60){
angka=sat;
data_ISD();
Next=0;
}
}
//==============================data ISD
void data_ISD(){
switch(angka){
chip.pu();
case '*':
chip.pu();
startAddr=0x15;
endAddr =0x1E;
chip.set_play(startAddr,endAddr);
break;
case 1:
//------------SATU
chip.pu();
startAddr=0x21;
endAddr =0x24;
chip.set_play(startAddr,endAddr);
break;
case 2:
//-------------DUA
chip.pu();
startAddr=0x29;
endAddr =0x2C;
chip.set_play(startAddr,endAddr);
break;
case 3:
//-------------TIGA
chip.pu();
startAddr=0x30;
endAddr =0x33;
chip.set_play(startAddr,endAddr);
break;
case 4:
//------------EMPAT
chip.pu();
startAddr=0x38;
endAddr =0x3A;
chip.set_play(startAddr,endAddr);
break;
case 5:
//------------LIMA
chip.pu();
startAddr=0x3F;
endAddr =0x41;
chip.set_play(startAddr,endAddr);
break;
case 6:
//------------ENAM
chip.pu();
startAddr=0x46;
endAddr =0x49;
chip.set_play(startAddr,endAddr);
break;
case 7:
//------------TUJUH
chip.pu();
startAddr=0x4E;
endAddr =0x50;
chip.set_play(startAddr,endAddr);
break;
case 8:
//------------DELAPAN
chip.pu();
startAddr=0x55;
endAddr =0x58;
chip.set_play(startAddr,endAddr);
break;
case 9:
//------------SEMBILAN
chip.pu();
startAddr=0x5D;
endAddr =0x60;
chip.set_play(startAddr,endAddr);
break;
case 'A':
//------------SEPULUH
chip.pu();
startAddr=0x65;
endAddr =0x68;
chip.set_play(startAddr,endAddr);
break;
case'B':
//------------SEBELAS
chip.pu();
startAddr=0x6D;
endAddr =0x70;
chip.set_play(startAddr,endAddr);
break;
case'C':
//------------BELAS
chip.pu();
startAddr=0x75;
endAddr =0x78;
chip.set_play(startAddr,endAddr);
break;
case'D':
//------------PULUH
chip.pu();
startAddr=0x7C;
endAddr =0x80;
chip.set_play(startAddr,endAddr);
break;
case'E':
//------------RATUS
chip.pu();
startAddr=0x84;
endAddr =0x88;
chip.set_play(startAddr,endAddr);
break;
case'F':
//------------SERATUS
chip.pu();
startAddr=0x8D;
endAddr =0x90;
chip.set_play(startAddr,endAddr);
break;
}
}
void tampil7Segment(){
if(rat>0){
digitalWrite(A0,LOW); digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
sevenSegWrite(rat);
delay(5);
}
if(pul>0 || rat>0){
digitalWrite(A0,HIGH); digitalWrite(A1,LOW);
digitalWrite(A2,HIGH);
sevenSegWrite(pul);
delay(5);
}
digitalWrite(A0,HIGH); digitalWrite(A1,HIGH);
digitalWrite(A2,LOW);
sevenSegWrite(sat);
delay(5);
tunda++;
}
void sevenSegWrite(byte segment){
byte pin = 2;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}
Jalannya Alat
1. Rekam suara antrian pada ISD. Untuk mendapatkan rekaman yang baik sebaiknya Anda
menggunakan koneksi output langsung dari output sound komputer/laptop. Cara merekam suara
Anda bisa lihat dari datasheet ISD17xx.
2. Selanjutnya pastikan library ISD1700 sudah terinstal.
3. Upload program diatas.
4. Kondisi awal seven segment menampilkan angka 0
sesuai dengan yang ada di display
6. Tekan tombol Return untuk memanggil ulang nomor antrian tanpa menambah nomor urut antrian.
Video untuk Project I - 13. Mesin Antrian 1 Loket dengan Tampilan 7-Segment berbasis Arduino
KONTAK KAMI 085743320570 (adi sanjaya)
No comments:
Post a Comment