Using SoundPAL or ColorPAL with Arduino board
Does anybody know how to interface an Arduino board to a SoundPAL or ColorPAL?
The SoundPAL docs specify that the circuit is to be Open-Collector and discuss how to do that for a Basic Stamp. I have learned before when interfacing it to the Propeller that you basically write code to send your bits serially to a pin only you set the DIRA register instead of the OUTA register when your write your data. Does anybody know how to do this for an Arduino board?
I tried to write a piece of code to do it like the Propeller which I pasted in below. Should I be using another method or is there just a bug somewhere in my code??? (*Note: Yes, I know, I posted this to the Arduino Forum also...)
// First attempt at using SoundPAL with Arduino board
#define PAL_PIN 1
#define BAUD 9600
#define IS_DEVICE_READY 0x3F
#define DEVICE_IS_READY 0xFF
#define START_QUEUE 0x3D
#define END_OF_QUEUE 0x00
#define PLAY_QUEUE 0x21
#define PLAY_ROM_SEQ 0x01
#define REPEAT_CODES 0x02
#define END_REPEAT 0x03
int bitTime;
void setup()
{
bitTime = 1000000 / BAUD;
}
void loop()
{
byte noteBuffer[noparse][[/noparse]10];
noteBuffer[noparse][[/noparse]0] = START_QUEUE;
noteBuffer = PLAY_ROM_SEQ;
noteBuffer = 0xAF;
noteBuffer = END_OF_QUEUE;
PlayNotes(¬eBuffer[noparse][[/noparse]0]);
}
void PlayNotes(byte *aBuffer)
{
byte aNote;
byte n = 0;
do
{
aNote = aBuffer[noparse][[/noparse]n++];
txChar(aNote);
}
while (aNote != 0);
}
void txChar(byte aChar)
{
word newChar = (aChar | 0x0100) << 2;
int t = 1;
do
{
newChar = ~(newChar >> 1) & 0x01;
if (newChar > 0)
pinMode(PAL_PIN, OUTPUT);
else
pinMode(PAL_PIN, INPUT);
delayMicroseconds(bitTime);
}
while (t++ < 10);
}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Often the joy is not so much in the having, its in the building...
The SoundPAL docs specify that the circuit is to be Open-Collector and discuss how to do that for a Basic Stamp. I have learned before when interfacing it to the Propeller that you basically write code to send your bits serially to a pin only you set the DIRA register instead of the OUTA register when your write your data. Does anybody know how to do this for an Arduino board?
I tried to write a piece of code to do it like the Propeller which I pasted in below. Should I be using another method or is there just a bug somewhere in my code??? (*Note: Yes, I know, I posted this to the Arduino Forum also...)
// First attempt at using SoundPAL with Arduino board
#define PAL_PIN 1
#define BAUD 9600
#define IS_DEVICE_READY 0x3F
#define DEVICE_IS_READY 0xFF
#define START_QUEUE 0x3D
#define END_OF_QUEUE 0x00
#define PLAY_QUEUE 0x21
#define PLAY_ROM_SEQ 0x01
#define REPEAT_CODES 0x02
#define END_REPEAT 0x03
int bitTime;
void setup()
{
bitTime = 1000000 / BAUD;
}
void loop()
{
byte noteBuffer[noparse][[/noparse]10];
noteBuffer[noparse][[/noparse]0] = START_QUEUE;
noteBuffer = PLAY_ROM_SEQ;
noteBuffer = 0xAF;
noteBuffer = END_OF_QUEUE;
PlayNotes(¬eBuffer[noparse][[/noparse]0]);
}
void PlayNotes(byte *aBuffer)
{
byte aNote;
byte n = 0;
do
{
aNote = aBuffer[noparse][[/noparse]n++];
txChar(aNote);
}
while (aNote != 0);
}
void txChar(byte aChar)
{
word newChar = (aChar | 0x0100) << 2;
int t = 1;
do
{
newChar = ~(newChar >> 1) & 0x01;
if (newChar > 0)
pinMode(PAL_PIN, OUTPUT);
else
pinMode(PAL_PIN, INPUT);
delayMicroseconds(bitTime);
}
while (t++ < 10);
}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Often the joy is not so much in the having, its in the building...
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Often the joy is not so much in the having, its in the building...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Often the joy is not so much in the having, its in the building...
-Phil