Go Down

Topic: Sign language with flex sensors (Read 1 time) previous topic - next topic

shrikant_arts

Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define FLEX_1  A0
#define FLEX_2  A1
#define FLEX_3  A2
const int sMin=950;
const int sMax=980;

void setup() {

  pinMode(FLEX_1,INPUT);
  pinMode(FLEX_2,INPUT);
  pinMode(FLEX_3,INPUT);
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Sign Language");
  Serial.begin(9600);
  delay(500);
}

void loop() {
  // put your main code here, to run repeatedly:
int s1=analogRead(A0);
int s2=analogRead(A1);
int s3=analogRead(A2);

if((s1>s2) && (s1>s3))
{
  int range1=map(s1,sMin,sMax,0,3);
  switch(range1)
  {
    case 0:
    lcd.noDisplay();
    Serial.println("no");
    break;
    case 1:
    lcd.display();
    lcd.setCursor(0,0);
    lcd.print("help");
    delay(1000);
    Serial.println("yes");
    break;
  }
}
if((s2>s1) && (s2>s3))
{
  int range2=map(s2,sMin,sMax,0,3);
  switch(range2)
  {
    case 0:
    lcd.noDisplay();
    Serial.println("no high");
    break;
    case 1:
    lcd.display();
    lcd.setCursor(0,0);
    lcd.print("call");
    delay(1000);
    Serial.println("yes call");
    break;
  }
}
if((s3>s1) && (s3>s2))
{
  int range3=map(s3,sMin,sMax,0,3);
  switch(range3)
  {
    case 0:
    lcd.noDisplay();
    Serial.println("no high");
    break;
    case 1:
    lcd.display();
    lcd.setCursor(0,0);
    lcd.print("call");
    delay(1000);
    Serial.println("yes call");
    break;
  }
}
}


Here is the code pls help me put


6v6gt

How does the behaviour of your code differ from your expectations ?
Can you explain why you have chosen to use 3 sensors for 3 messages. Why not just one and depending on the range returned by analogRead(), chose the appropriate message to display ?

shrikant_arts

yes i have choosen 3 because, i need to show a sign language demonstration for deaf and dumb people, so istead of 5 flexsensors i have used 3 to show 3 demostration messages for the people who cannot speak.

beofre that i was checking whether its working or not,
then i hv started with 3 so getting problem

6v6gt


shrikant_arts

Isnt getting any value.
U need a respective msg to be displayed on rhe lxs for respective sensor.thats it.but the values are automaticly cmng n going



6v6gt

You seem to have a problem expressing yourself clearly and answering questions when these are asked. It is also not clear, even looking at the code what you are trying to do in detail.

Anyway, maybe you can answer these questions:

1. For how many seconds must a user hold the flex sensor in a particular position before it determines what message the user wants to have displayed ?

2. Once it is clear what message the user wants displayed, for how many seconds must the message remain in the display ?

3. If more than one flex sensor is activated, which should take priority ?


Also:

You should have debug (Serial.print) statements in your code to cover all conditions so you can see what is happening. For example, what happens if switch(range2) returns a 2 or even a 3 ? . You wont see that.

shrikant_arts

Im sorry that you arr unable to get me.
Here is the thing.

Im making a sign language for deaf and dumb people using flexsensors which will be attach to the gloves.

Im using only 3 flex sensors .
Each flex sensor on bending any time would display a message on the lcd.

3 flex sensors so it is comination of 8 output.


Because deaf and dumb.cont convey thejr message properly.
Im in a way to regard them.



So i have wriiten a code
Saying s1 s2 s3.
S1 for flexsensor 1
S2 for flexsensor 2
S3 for flexsensor 3.


You can chck the code.
At ant time.
If i flex these sensor i shpuld probably get a texf on my lcd.
Each sensor mappinh would be different.


The problm.is sir im unable to gwt these outputs..aa i wrote ij thw code.


Hopw u got the overall idea sir.

6v6gt

This part was already clear:
Quote
Im making a sign language for deaf and dumb people using flexsensors which will be attach to the gloves.
But you want to derive 8 values from 3 flex sensors to generate 8 messages.

I'd recommend starting with  something simple which prints numbers 0 through to 7 on the serial console, depending on the positions of the sensors.

Once you have done that, associate a message with each number and then print that message onto the LCD. I guess that 0 will be "no message".

Anyway, I've modified the code as it is to put out some debug statements in the hope that it is clear to you what it is doing. If you have problems, you should post the relevant part of the debug output together with a clear statement of how you were testing it and explanation of why you think it is wrong.

Code: [Select]


#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define FLEX_1  A0
#define FLEX_2  A1
#define FLEX_3  A2
const int sMin = 950;
const int sMax = 980;

void setup() {

  pinMode(FLEX_1, INPUT);
  pinMode(FLEX_2, INPUT);
  pinMode(FLEX_3, INPUT);
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Sign Language");
  Serial.begin(9600);
  delay(500);
}

void loop() {
  // put your main code here, to run repeatedly:
  int s1 = analogRead(A0);
  int s2 = analogRead(A1);
  int s3 = analogRead(A2);

  if ((s1 > s2) && (s1 > s3))
  {

    int range1 = map(s1, sMin, sMax, 0, 3);
    Serial.print("in s1. analogRead=") ; Serial.print( s1 ) ; Serial.print(", range1= " ) ; Serial.println( range1 ) ;
    switch (range1)
    {
      case 0:
        lcd.noDisplay();
        Serial.println("no");
        break;
      case 1:
        lcd.display();
        lcd.setCursor(0, 0);
        lcd.print("help");
        delay(1000);
        Serial.println("yes");
        break;
      default: Serial.println( "no valid case found range1" ) ;
    }
  }
  if ((s2 > s1) && (s2 > s3))
  {
    int range2 = map(s2, sMin, sMax, 0, 3);
    Serial.print("in s2. analogRead=") ; Serial.print( s2 ) ; Serial.print(", range2= " ) ; Serial.println( range2 ) ;
    switch (range2)
    {
      case 0:
        lcd.noDisplay();
        Serial.println("no high");
        break;
      case 1:
        lcd.display();
        lcd.setCursor(0, 0);
        lcd.print("call");
        delay(1000);
        Serial.println("yes call");
        break;
      default: Serial.println( "no valid case found range2" ) ;
    }
  }
  if ((s3 > s1) && (s3 > s2))
  {
    int range3 = map(s3, sMin, sMax, 0, 3);
    Serial.print("in s3. analogRead=") ; Serial.print( s3 ) ; Serial.print(", range3= " ) ; Serial.println( range3 ) ;
    switch (range3)
    {
      case 0:
        lcd.noDisplay();
        Serial.println("no high");
        break;
      case 1:
        lcd.display();
        lcd.setCursor(0, 0);
        lcd.print("call");
        delay(1000);
        Serial.println("yes call");
        break;
      default: Serial.println( "no valid case found range3" ) ;
    }
  }
  delay(200) ; // only for testing to reduce serial console activity
}









Go Up