Go Down

Topic: Flex sensor problems (Read 163 times) previous topic - next topic

Mijasenpai

Hi. I'm in the process of making "a gesture vocalizer" project where I use 5 flex sensor as a input to the microcontroller arduino Mega where it will give around 10 output or more.

I managed to make it display on LCD when each flex sensor bend. However, when I want multiple flex sensor to bend, it does not work.

Below is the code that I did:

Code: [Select]


#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
const int ledPin=13;

#define FLEX_1 A0
#define FLEX_2 A1
#define FLEX_3 A2

const int sMin=950;
const int sMax=820;

void setup()
{
pinMode(FLEX_1,INPUT);
pinMode(FLEX_2,INPUT);
pinMode(FLEX_3,INPUT);
pinMode(ledPin,OUTPUT);
Serial.begin(9600);

void loop()
{
int s1=analogRead(A0);
int s2=analogRead(A1);
int s3=analogRead(A2);

if (s1>s2)

{
int range1=map(s1,sMin,sMax,0,4);
Serial.print(s1);
switch(range1);
     {
       case 0:
       Serial.println("no");
       break;

       case 1:
       lcd init();
       lcd.backlight();
       lcd.setCursor(0,0);
       lcd.print("HELLO");
       delay(3000);
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       break;

       default: Serial.println("Not found");
}
        delay(200);
}

if (s2>s1)

{
int range2=map(s2,sMin,sMax,0,4);
Serial.print(s2);
switch(range2);
     {
       case 0:
       Serial.println("no");
       break;

       case 1:
       lcd init();
       lcd.backlight();
       lcd.setCursor(0,0);
       lcd.print("HELP ME");
       delay(3000);
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       break;

       default: Serial.println("Not found");
}
        delay(200);

}

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

{
int range3=map(s3,sMin,sMax,0,4);
Serial.print(s3);
switch(range3);
     {
       case 0:
       Serial.println("no");
       break;

       case 1:
       lcd init();
       lcd.backlight();
       lcd.setCursor(0,0);
       lcd.print("MEDICINE");
       delay(3000);
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       break;

       default: Serial.println("Not found");
}
        delay(200);

}

if (s1&&s2>s3)

{
int range1=map(s1&&s2,sMin,sMax,0,4);
Serial.print(S1&S2);
switch(range4);
     {
       case 0:
       Serial.println("no");
       break;

       case 1:
       lcd init();
       lcd.backlight();
       lcd.setCursor(0,0);
       lcd.print("IM SICK");
       delay(3000);
       digitalWrite(13,HIGH);
       delay(500);
       digitalWrite(13,LOW);
       break;

       default: Serial.println("Not found");
}
        delay(200);
}

}



I know there is wrong with the last one, but i try to figure out for several times but it doesn't work.

wvmarle

First of all, please explain what you mean exactly with "it does not work".
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Mijasenpai

It does not work = nothing happen and no display on the lcd

Go Up