// ** This file was downloaded from: // ** http://www.afox-consulting.com//product/DigiTalkerInterfaceBoard.html // ** File: DigiTalker.ino // ** Author: A Fox Consulting & Design // ** Date: 05/12/2014 // // ** DISCLAIMER: This source code was written to interface with a // ** specific in-house prototype product developed by A Fox Consulting // ** And Design. The code here is experimental and is meant to provide // ** proof-of-concept of the device only and is not intended for // ** commercial use. // // This is a sample source code file to demonstrate // our DigiTalker I2C Interface Board. // // Wiring set-up: // Digital 5 --> To DigiTalker ~INTR (pin 6) // Digital 6 --> To DigiTalker CS (pin 3) // Digital 7 --> To DigiTalker ~WR (pin 4) #include "Wire.h" #define pDIGI_INTR 5 #define pDIGI_CS 6 #define pDIGI_WR 7 #define MCP_ADDR 0x20 // The MCP230008 can have an address from 0x20 - 0x27 #define WordDataL 56 // Some silly sentences to send to DigiTalker word WordData[56] = { 0, 71, 65, 2, 121, 2, 80, 129, 5, 71, 81, 70, 81, 70, 76, 76, 76, 66, 66, 0x46, 0x46, 0x46, 0x46, 0x46, 0x53, 0x4B, 0x60, 0x75, 0x03, 0x1D, 0x52, 0x47, 0x47, 0x07, 0x09, 0x7A, 0x04, 0x4D, 0x81, 0x47, 0x47, 0x78, 0x49, 0x8E, 0x43, 0x6A, 0x20, 0x01, 0x47, 0x41, 0x45, 0x41, 0x45, 0x42, 0x47, 0x42 }; void SayWord (byte value) { Wire.beginTransmission(MCP_ADDR); Wire.write(0x09); // Start writing at register GPIO Wire.write(value); // Write "value" to GPIO port Wire.endTransmission(); // Do the write digitalWrite(pDIGI_CS, 0); digitalWrite(pDIGI_WR, 0); delayMicroseconds(2000); digitalWrite(pDIGI_WR, 1); digitalWrite(pDIGI_CS, 1); while(!digitalRead(pDIGI_INTR)) {}; } // -------------------------------------------------------------------------------- void setup() { pinMode(pDIGI_INTR, INPUT); pinMode(pDIGI_WR, OUTPUT); pinMode(pDIGI_CS, OUTPUT); digitalWrite(pDIGI_WR, 1); // Set DigiTalker ~WR HIGH digitalWrite(pDIGI_CS, 1); // Set DigiTalker Chip Select HIGH delay(1000); Wire.begin(); Wire.beginTransmission(MCP_ADDR); // Available addresses are 0x20 - 0x27 Wire.write((byte)0x00); // Start at IODIR register Wire.write((byte)0x00); // Set all of GPIO port to OUTPUT Wire.endTransmission(); } // -------------------------------------------------------------------------------- // High-Level code begins here // -------------------------------------------------------------------------------- void loop() { byte i = 0; for(i=0;i<150;i++) { //SayWord(WordData[i]); SayWord(i); delay(1000); } delay(5000); }