Advertisement
j0h

bbt ardunio

j0h
Oct 13th, 2021
1,342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.07 KB | None | 0 0
  1. #include <SPI.h>    // include the SPI communcation library
  2. // Connect pin#13 (SCLK) To S2 on AP23
  3. // Connect pin#11 (DATOUT) To S3 on AP23
  4. // Connect pin#13 (SCLK) To S2 on AP23
  5. // Connect pin#10 (CS) To S1 on AP23
  6. // DO from Ap23 optional S4 - Not used here
  7. #define cs 10          // These are the chip-select pins for SPI. They control chips 1-4
  8. #define cs2 9
  9. #define cs3 8
  10. #define cs4 7
  11. int hold = 0;       // Integer used when calling words
  12. int del=200;        // short 200ms delay
  13. int play = 0x98;  // play command - This value never changes
  14. int value2 = 0;  // voice address - when you place a hex value in this integer and call the "readout()" function, that specific word will play
  15. int value3 = 0xA8;  // COUT ramp up - This value never changes
  16. int value4 = 0xB8;   // COUT ramp down - This value never changes
  17. // ALL OF THE ABOVE CODE IS REQUIRED FOR THE OPERATION OF THE LBT
  18.  
  19. void setup()  // Set up SPI
  20. {Serial.begin(9600);
  21.   SPI.begin();             // Initialize SPI
  22.   SPI.setClockDivider(SPI_CLOCK_DIV32); // low frequency SPI
  23.   pinMode(cs,OUTPUT);    // Chip select pins is an output
  24.   pinMode(cs2,OUTPUT);    // Chip select pins is an output
  25.   pinMode(cs3,OUTPUT);    // Chip select pins is an output
  26.   pinMode(cs4,OUTPUT);    // Chip select pins is an output
  27.   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.
  28.   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.
  29.   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.
  30.   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.
  31.   SPI.setBitOrder(MSBFIRST);  // OTP requires MSB first
  32.   SPI.setDataMode(SPI_MODE0);  // Use MODE0, as all other modes to not work
  33.   value2 = 0x00; // Start at voice group 0
  34.   delay(1000);   // One second delay
  35.   // The following code sets up the output of each chip.  
  36.   digitalWrite(cs,LOW);
  37.   SPI.transfer(value3);
  38.   SPI.transfer(0x00);
  39.   digitalWrite(cs,HIGH);
  40.   delay(5);
  41.   digitalWrite(cs2,LOW);
  42.   SPI.transfer(value3);
  43.   SPI.transfer(0x00);
  44.   digitalWrite(cs2,HIGH);
  45.   delay(5);
  46.    digitalWrite(cs3,LOW);
  47.   SPI.transfer(value3);
  48.   SPI.transfer(0x00);
  49.   digitalWrite(cs3,HIGH);
  50.   delay(5);
  51.   digitalWrite(cs4,LOW);
  52.   SPI.transfer(value3);
  53.   SPI.transfer(0x00);
  54.   digitalWrite(cs4,HIGH);
  55.   value2 = 0;   // THIS STARTS THE POINTER AT WORD 0
  56. }
  57.  
  58.  
  59.  
  60. void loop()             // IN THIS LOOP, ALL WORDS ARE PLAYED SEQUENTIALLY. VALUE2 INTEGER IS INCREMENTED AFTER EVERY WORD PLAYED.
  61. {
  62.  
  63.   digitalWrite(cs4,LOW);   // Talk to chip#1
  64.   Serial.print("The value of CS ");
  65.   Serial.println(cs4);
  66.   //cs=10
  67.   //cs2=9
  68.   //cs3=8
  69.   //cs4=7
  70.   SPI.transfer(play);   // Send command to play
  71.   SPI.transfer(3);     // Call
  72.   digitalWrite(cs4,HIGH);  // Stop talking to chip.  The word will be said by the BBT at this time
  73.   delay(850);
  74.  
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement