Dear LMRs,
This code below is by ICStation
http://www.instructables.com/id/APR9600-Voice-Recording-and-Playback-System-with-J/
They use a code works like this : when you press button 1 , Arduino instructs Audio record chip APR9600 to play first recorded msg whaich is (First floor) and so other buttons.
I know this is an ideal example of using matrix instead of line by line. but how ?
#define uchar unsigned char #define uint unsigned int uint Key_1=30; uint Key_2=31; uint Key_3=32; uint Key_4=33; uint Key_5=34; uint Key_6=35; uint Key_7=36; uint Key_8=37; uint Code_1=3; uint Code_2=4; uint Code_3=5; uint Code_4=6; uint Code_5=7; uint Code_6=8; uint Code_7=9; uint Code_8=10;void setup()
{
pinMode(Key_1,INPUT);
pinMode(Key_2,INPUT);
pinMode(Key_3,INPUT);
pinMode(Key_4,INPUT);
pinMode(Key_5,INPUT);
pinMode(Key_6,INPUT);
pinMode(Key_7,INPUT);
pinMode(Key_8,INPUT);
pinMode(Code_1,OUTPUT);
pinMode(Code_2,OUTPUT);
pinMode(Code_3,OUTPUT);
pinMode(Code_4,OUTPUT);
pinMode(Code_5,OUTPUT);
pinMode(Code_6,OUTPUT);
pinMode(Code_7,OUTPUT);
pinMode(Code_8,OUTPUT);
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
digitalWrite(Key_1,HIGH);
digitalWrite(Key_2,HIGH);
digitalWrite(Key_3,HIGH);
digitalWrite(Key_4,HIGH);
digitalWrite(Key_5,HIGH);
digitalWrite(Key_6,HIGH);
digitalWrite(Key_7,HIGH);
digitalWrite(Key_8,HIGH);
}void loop()
{
if(digitalRead(Key_1)==0)
{
delay(10);
if(digitalRead(Key_1)==0)
{
digitalWrite(Code_1,LOW);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_1)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_2)==0)
{
delay(10);
if(digitalRead(Key_2)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,LOW);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_2)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_3)==0)
{
delay(10);
if(digitalRead(Key_3)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,LOW);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_3)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_4)==0)
{
delay(10);
if(digitalRead(Key_4)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,LOW);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_4)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_5)==0)
{
delay(10);
if(digitalRead(Key_5)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,LOW);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_5)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_6)==0)
{
delay(10);
if(digitalRead(Key_6)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,LOW);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_6)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_7)==0)
{
delay(10);
if(digitalRead(Key_7)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,LOW);
digitalWrite(Code_8,HIGH);
delay(10);
}
if(digitalRead(Key_7)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}if(digitalRead(Key_8)==0)
{
delay(10);
if(digitalRead(Key_8)==0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,LOW);
delay(10);
}
if(digitalRead(Key_8)!=0)
{
digitalWrite(Code_1,HIGH);
digitalWrite(Code_2,HIGH);
digitalWrite(Code_3,HIGH);
digitalWrite(Code_4,HIGH);
digitalWrite(Code_5,HIGH);
digitalWrite(Code_6,HIGH);
digitalWrite(Code_7,HIGH);
digitalWrite(Code_8,HIGH);
delay(10);
}
}
}