Go Down

Topic: Arduino and Speakjet (Read 112 times) previous topic - next topic

Robomicro

Casebased Trigger  for Speakjet

/*
  SpeakJet Phrase Trigger Example
  //This will trigger a sound
  //Input the number "1" speaks "Hello"
  //Input the number "2" speaks "Yeah"
  //Input teh number "3" speaks "uuwww"
  //This code is  to show  how to set up a case based arguement
  //Upload to Arduino and send data via the built in serial monitor

 */
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
// Create a new software serial port object called "speakJet"
SoftwareSerial speakJet =  SoftwareSerial(rxPin, txPin);
int TheReadByte = 0;
void setup() {
    // Configure software serial port pins for SpeakJet
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  speakJet.begin(9600);       // The SpeakJet defaults to 9600bps
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}
void loop() {
//wait for data in the serial port...
if (Serial.available() == 0)
{
}
else

  //bye is available in the buffer
   //read it
   TheReadByte = Serial.read();
  switch (TheReadByte)
  {
    //case A - send message 1 to the speakjet
    case '1':
      speakJet.write(183);
      speakJet.write(130);
      speakJet.write(146);
      speakJet.write(8);
      speakJet.write(137);
       speakJet.write(8);
     
      break;

    //case B - send message 2 to the speakjet
    case '2':
      speakJet.write(158);
      break;

    //case C - send message 3 to the speakjet
    case '3':
      speakJet.write(162);
      break;     
     
       //case D - send message 3 to the speakjet
    case '4' :
      speakJet.write(155);
      break; 
  } 
}
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy