APR9600-Arduino_Random.jpg (79107Bytes)
Based on a talking-lift-buttons project published on instructables (credits to ICstation); I have modified the schematic to the following:
- Arduino Nano controls the audio storage chip APR9600 which includes 8 messages.
- Arduino generates random 8 numbers
- each number calls one of the 8 messages.
The result, it will look like as if the Arduino is talking out of its own mind.(more realistic if we extend this systems into say 50 phrases or more which may need a different audio storage module than APR9600)
I have assembled the scketch but its not working. i can use some advice please
#define APR9600 audion chip controlled by arduino
#define uint unsigned int
int ranNum;
int ranDel;
void setup()
{
// Seed RNG from analog port.
randomSeed(analogRead(0));
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A5,OUTPUT);
pinMode(A6,OUTPUT);
pinMode(A7,OUTPUT);
pinMode(A3,OUTPUT);
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
}
void loop()
{
//Generate random number between 8 and 10
ranNum=random(1,9);
// Generate random delay time
ranDel=random(25,300);
if(ranDel==1)
{
delay(10);
if(ranDel==1)
{
digitalWrite(A0,LOW);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==2)
{
delay(10);
if(ranDel==2)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,LOW);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==3)
{
delay(10);
if(ranDel==3)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,LOW);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==4)
{
delay(10);
if(ranDel==4)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,LOW);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==5)
{
delay(10);
if(ranDel==5)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,LOW);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==6)
{
delay(10);
if(ranDel==6)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,LOW);
digitalWrite(A6,HIGH);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==7)
{
delay(10);
if(ranDel==7)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,LOW);
digitalWrite(A7,HIGH);
delay(10);
}
}
if(ranDel==8)
{
delay(10);
if(ranDel==8)
{
digitalWrite(A0,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(A2,HIGH);
digitalWrite(A3,HIGH);
digitalWrite(A4,HIGH);
digitalWrite(A5,HIGH);
digitalWrite(A6,HIGH);
digitalWrite(A7,LOW);
delay(10);
}
}
}