Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h> // include the SPI communcation library
- // Connect pin#13 (SCLK) To S2 on AP23
- // Connect pin#11 (DATOUT) To S3 on AP23
- // Connect pin#13 (SCLK) To S2 on AP23
- // Connect pin#10 (CS) To S1 on AP23
- // DO from Ap23 optional S4 - Not used here
- #define cs 10 // These are the chip-select pins for SPI. They control chips 1-4
- #define cs2 9
- #define cs3 8
- #define cs4 7
- int hold = 0; // Integer used when calling words
- int del=200; // short 200ms delay
- int play = 0x98; // play command - This value never changes
- int value2 = 0; // voice address - when you place a hex value in this integer and call the "readout()" function, that specific word will play
- int value3 = 0xA8; // COUT ramp up - This value never changes
- int value4 = 0xB8; // COUT ramp down - This value never changes
- // ALL OF THE ABOVE CODE IS REQUIRED FOR THE OPERATION OF THE LBT
- void setup() // Set up SPI
- {Serial.begin(9600);
- SPI.begin(); // Initialize SPI
- SPI.setClockDivider(SPI_CLOCK_DIV32); // low frequency SPI
- pinMode(cs,OUTPUT); // Chip select pins is an output
- pinMode(cs2,OUTPUT); // Chip select pins is an output
- pinMode(cs3,OUTPUT); // Chip select pins is an output
- pinMode(cs4,OUTPUT); // Chip select pins is an output
- digitalWrite(cs,HIGH); // Set chip select to be HIGH (5v) by default. The chip on the shield is selected when this line is brought low.
- digitalWrite(cs2,HIGH); // Set chip select to be HIGH (5v) by default. The chip on the shield is selected when this line is brought low.
- digitalWrite(cs3,HIGH); // Set chip select to be HIGH (5v) by default. The chip on the shield is selected when this line is brought low.
- digitalWrite(cs4,HIGH); // Set chip select to be HIGH (5v) by default. The chip on the shield is selected when this line is brought low.
- SPI.setBitOrder(MSBFIRST); // OTP requires MSB first
- SPI.setDataMode(SPI_MODE0); // Use MODE0, as all other modes to not work
- value2 = 0x00; // Start at voice group 0
- delay(1000); // One second delay
- // The following code sets up the output of each chip.
- digitalWrite(cs,LOW);
- SPI.transfer(value3);
- SPI.transfer(0x00);
- digitalWrite(cs,HIGH);
- delay(5);
- digitalWrite(cs2,LOW);
- SPI.transfer(value3);
- SPI.transfer(0x00);
- digitalWrite(cs2,HIGH);
- delay(5);
- digitalWrite(cs3,LOW);
- SPI.transfer(value3);
- SPI.transfer(0x00);
- digitalWrite(cs3,HIGH);
- delay(5);
- digitalWrite(cs4,LOW);
- SPI.transfer(value3);
- SPI.transfer(0x00);
- digitalWrite(cs4,HIGH);
- value2 = 0; // THIS STARTS THE POINTER AT WORD 0
- }
- void loop() // IN THIS LOOP, ALL WORDS ARE PLAYED SEQUENTIALLY. VALUE2 INTEGER IS INCREMENTED AFTER EVERY WORD PLAYED.
- {
- digitalWrite(cs4,LOW); // Talk to chip#1
- Serial.print("The value of CS ");
- Serial.println(cs4);
- //cs=10
- //cs2=9
- //cs3=8
- //cs4=7
- SPI.transfer(play); // Send command to play
- SPI.transfer(3); // Call
- digitalWrite(cs4,HIGH); // Stop talking to chip. The word will be said by the BBT at this time
- delay(850);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement