Newbie help needed with sketch

ktnch

New member
Hi there, im trying to follow a sketch but the sketch says include sound.h, now i cant find that library anywhere only Audio.h but when i use that i get all kinds of errors

were using a itsybitsy m4 express board


Code:
#include <english.h>
#include <Sound.h>
#include <TTS.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LSM9DS1.h>
#include <Adafruit_Sensor.h>  

// i2c, initialize the sensor breakout board
Adafruit_LSM9DS1 lsm = Adafruit_LSM9DS1();

#define LSM9DS1_SCK 21
#define LSM9DS1_MISO 12
#define LSM9DS1_MOSI 20
#define LSM9DS1_XGCS 6
#define LSM9DS1_MCS 5

void setupSensor()
{
  // Set the magnetometer sensitivity
  lsm.setupMag(lsm.LSM9DS1_MAGGAIN_4GAUSS);
}

// Dictionary of the 1000 most common English words.
char *words[] = {"the", "of", "to", "and", "a", "in", "is", "it", "you", "that", "he", "was", "for", "on", "are", "with", "as", "I", "his", "they", "be", "at", "one", "have", "this", "from", "or", "had", "by", "hot", "word", "but", "what", "some", "we", "can", "out", "instant", "market", "degree", "populate", "chick", "dear", "enemy", "reply", "drink", "occur", "support", "speech", "nature", "range", "steam", "motion", "path", "liquid", "log", "meant", "quotient", "teeth", "shell", "neck"};

// Media pins
#define PWM A0
#define buttonPin 13

//TTS text2speech(PWM);  // default is digital pin 10
int buttonState = 0;
float lastMag = 0;
float lastTemp = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  Serial.begin(115200);
  // Try to initialise and warn if we couldn't detect the chip
  if (!lsm.begin())
  {
    Serial.println("Oops ... unable to initialize the LSM9DS1. Check your wiring!");
    while (1);
  }
  setupSensor();
}

void loop() {
  buttonState = digitalRead(buttonPin);
  // Check if the switch has been thrown. If so, start measuring and speaking.
  if (buttonState == HIGH) {
    lsm.read();  /* ask it to read in the data */

    /* Get a new sensor event */
    sensors_event_t a, m, g, temp;

    lsm.getEvent(&a, &m, &g, &temp);
    // Get the latest magnetometer and temperature reading
    float newMag = sqrt(sq(m.magnetic.x) + sq(m.magnetic.y) + sq(m.magnetic.z));
    float newTemp = temp.temperature;
    // If this isn't our first reading...
    if (lastMag != 0) {
      // Calculate the change in magnetic field/temperature
      float deltaMag = abs(newMag - lastMag);
      float deltaTemp = abs(newTemp - lastTemp);
      // Get the biggest change of the two
      float index = max(deltaMag, deltaTemp);
      // Convert to an index of our dictionary array
      float wordindfloat = index * 1000.0;
      int wordindint = round(wordindfloat);
      // Speak the change on teh speaker
      text2speech.setPitch(6);
     text2speech.sayText(words[wordindint]);
      Serial.println(words[wordindint]);
      // Store the readings for the next loop
      lastMag = newMag;
      lastTemp = newTemp;
    }
    // Store our readings as a baseline
    else {
      lastMag = newMag;
      lastTemp = newTemp;
    }
    delay(1000);
  }
}
 
Thank you for the reply

now we have this error ?

warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 
Back
Top