FSR in translating braille characters into speech

I'm sorry for my past posts being a part by part questions about our project. We're currently facing several problems in translating text to speech, The speaker only beeps every now and then, I've tested sample sounds from talkie and it works fine with the hardware/speaker. Only problem is that the speaker only gives beep every loop (Also open for recommendation about the code) (Short expl. for the proj. We want 6 FSR to correspond to each braille dots and translate it into text and then the text into speech)

#include <Talkie.h>

Talkie voice;

const int pressureAnalogPins[] = {0, 1, 2, 3, 4, 5}; // Pins where our pressure pads are located
const int numPressureAnalogPins = 6; // Number of pressure analog pins
int pressureReading; // Variable for storing our reading

const int noPressure = 2; // Max value for no pressure on the pad
const int lightPressure = 50; // Max value for light pressure on the pad
const int mediumPressure = 100; // Max value for medium pressure on the pad

bool brailleDots[6] = {false}; // Array to store whether a braille dot is sensed for each pin

const int speakerPin = 8; // Speaker pin

void setup(void) {
  Serial.begin(9600);
  pinMode(speakerPin, OUTPUT); // Initialize speaker pin
}

void loop(void) {
  // Reset braille dots array
  for (int i = 0; i < 6; i++) {
    brailleDots[i] = false;
  }

  // Read pressure on each pin
  for (int i = 0; i < numPressureAnalogPins; i++) {
    int currentPressureAnalogPin = pressureAnalogPins[i];
    pressureReading = analogRead(currentPressureAnalogPin);

    Serial.print("Pressure Pad ");
    Serial.print(i + 1);
    Serial.print(" Reading = ");
    Serial.println(pressureReading);

    // Determine if pressure indicates a braille dot
    if (pressureReading < noPressure) {
      // No pressure, do nothing
    } else if (pressureReading < lightPressure) {
      // Light pressure, set braille dot flag
      brailleDots[i] = true;
    } else if (pressureReading < mediumPressure) {
      // Medium pressure, set braille dot flag
      brailleDots[i] = true;
    } else {
      // High pressure, do nothing
    }
    delay(200);
  }

  // Determine the sensed braille pattern
  int braillePattern = 0;
  for (int i = 0; i < 6; i++) {
    if (brailleDots[i]) {
      braillePattern |= (1 << i); // Set the corresponding bit in the braille pattern
    }
  }

  // Translate braille pattern into text
  String text = brailleToText(braillePattern);

  // Output result
  Serial.print("Text formed: ");
  Serial.println(text);

  // Convert text to speech
  speak(text);

  delay(2000); // Delay between letters
}

String brailleToText(int braillePattern) {
  switch (braillePattern) {
    case 1: return "A";
    case 2: return "B";
    case 3: return "C";
    case 4: return "D";
    case 5: return "E";
    case 6: return "F";
    case 7: return "G";
    case 8: return "H";
    case 9: return "I";
    case 10: return "J";
    case 11: return "K";
    case 12: return "L";
    case 13: return "M";
    case 14: return "N";
    case 15: return "O";
    case 16: return "P";
    case 17: return "Q";
    case 18: return "R";
    case 19: return "S";
    case 20: return "T";
    case 21: return "U";
    case 22: return "V";
    case 23: return "W";
    case 24: return "X";
    case 25: return "Y";
    case 26: return "Z";
    default: return ""; // No letter formed
  }
}

void speak(String text) {
  // Say the text
  voice.say(text.c_str()); // Convert String to const char*

  // Generate tone through speaker
  tone(speakerPin, 1000, 200); // Adjust frequency and duration as needed
}


you should not create new posts if it's the same project

1 Like
const int pressureAnalogPins[] = {0, 1, 2, 3, 4, 5}; // Pins where our pressure pads are located

Please confirm that you have the sensors connected to pins A0 to A5 and not pins 0 to 5

this does not match the dots you described last time

what dot are reading the sensors you have in

this does not match the dots you described last time


which talkie library are you using ? (GitHub - ArminJo/Talkie: Refurbished Arduino version of the Talkie library from Peter Knight. ??)

Where do you store the vocabulary used in speak(text);?

Are you sure that your controller can manage dynamic memory (String)?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.