EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / PROBLEM IN USING FLEX SENSOR

PROBLEM IN USING FLEX SENSOR

|

Microcontroller › AVR › PROBLEM IN USING FLEX SENSOR

  • This topic has 3 replies, 2 voices, and was last updated 11 years, 4 months ago by Ashutosh Bhatt.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 2, 2014 at 9:10 am #3283
    himanshu mittal
    Participant

    sir/mam

        I am  getting problem in interfacing  5 flex sensors at a time . i am using flex sensors as fingers and want to control motion of motors with respect to flex sensors. But when i am using 5 flex sensors at a time the delay i introduced in setting motors on , that is creating problem for me . please help

    October 5, 2014 at 5:52 pm #12264
    Ashutosh Bhatt
    Participant

    at the same time you can not get input from all 5 sensors.

    you have to use  TDM technique. means one by one take input from all 5 sensors so fast that it feels like you are getting data at the same time. 

    to rotate motor you have to apply some delay to let the motor rotate

    October 6, 2014 at 4:53 pm #12265
    himanshu mittal
    Participant

    That delay i am introducing in rotating motors is causing problem for me.when my function is in delay loops obeviously it will not in read ADC value from all five sensors. I can’t understand how to program such that  my program reads all ADC value continouly and my motors respond to quickly to ADC value without facing the problem of delay.

     

    This is my program for two flex sensors ..

    That delay is main rival..
     
     
    #include <avr/io.h>
    #include <avr/LCD2014.h>
     
     
    delay(unsigned int d)
    {
    int i,j;
    for (i=0;i<d;i++)
    {
    for (j=0;j<1000;j++)
    {
    }
    }
    }
     
    int main(void)
    {    
    int x=0,y=0;               // x for green, y for red
    lcd_init();
    DDRB=0xff;
    ADCSRA=0x87;
    int a=0,b=0;
    while (1)
    {   
    ADMUX=0x20;
            ADCSRA|=(1<<ADSC);
            while((ADCSRA&(1<<ADIF))==0);
            x=ADCH;
    ADMUX=0x20;
            ADCSRA|=(1<<ADSC);
            while((ADCSRA&(1<<ADIF))==0);
           y=ADCH;
     
     
     
    if (x>=180 && x<=192 && a==0)
    {
    a=1;
            CLEARBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    }
    if (x>=197 && x<=207 && a==1)
    {
    a=2;
          SETBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    delay(150);
         CLEARBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    }
    if (x>=212 && a==2)
    {
    a=3;
         SETBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    delay(150);
       CLEARBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    }
     
    if (x<=208 && x>=200 && a==3)
    {
    a=4;
         CLEARBIT(PORTB,BIT0);
    SETBIT(PORTB,BIT1);
    delay(150);
         CLEARBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    }
    if (x<=196 && x>=188 && a==4)
    {
    a=0;
           CLEARBIT(PORTB,BIT0);
    SETBIT(PORTB,BIT1);
    delay(150);
            CLEARBIT(PORTB,BIT0);
    CLEARBIT(PORTB,BIT1);
    }
     
    if (y>=190 && y<=202 && b==0)
    {
    b=1;
          CLEARBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
    }
     
     
     
    if (y>=207 && y<=217 && b==1)
    {
    b=2;
            SETBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
    delay(1500);
            CLEARBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
    }
     
     
     
     
     
    if (y>=222 && b==2)
    {
    b=3;
            SETBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
    delay(1500);
            CLEARBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
          }
     
     
     
      if (y<=218 && y>=210 && b==3)
     {
    b=4;
            CLEARBIT(PORTB,BIT2);
    SETBIT(PORTB,BIT3);
    delay(1500);
            CLEARBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
    }
     
     
     
    if (y<=206 && y>=198 && b==4)
    {
    b=0;
            CLEARBIT(PORTB,BIT2);
    SETBIT(PORTB,BIT3);
     delay(1500);
           CLEARBIT(PORTB,BIT2);
    CLEARBIT(PORTB,BIT3);
    }
     
     
     
    lcd_value(x);
     lcd_cmd(LINE2);
    lcd_showvalue(y);
    delay(10);
    }
    }
     
    October 8, 2014 at 6:28 pm #12269
    Ashutosh Bhatt
    Participant

    I told you TDM technique. that means you have to use timer interrupt. 

    say after every 200 ms timer interrupt generated and it reads 1st flex sensor value

    after another 200 ms (means 400 ms) again interrupt generated and it reads 2nd flex sensor value

    like wise in every 1 sec you can read values from all 5 sensors.

    meanwhile in continuous loop you just keep on rotating motors with new updated values of sensor

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • ANOTHER OLD PROJECT REDO February 11, 2026
  • RC Electronic Speed Control Capacitors February 11, 2026
  • CR2/CR123A Batteries In Projects February 11, 2026
  • Variable audio oscillator February 11, 2026
  • XLR splitter to mono. February 11, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise