Pages: [1]   Go Down
Author Topic: Flex sensor  (Read 1871 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 134
We were born naked, wet and hungry. And then things get worse!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I just purchased a flex sensor. It seems to be working fine. I need some help with it. Every time, the value of the flex sensor reduces by 5k I want a dc geared motor to spin for .5 sec and for every 5k increase, it must pin in anti clock wise directioni for .5 sec. Could some one please give me a code for this.

Thankyou
Regards
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50928
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Could some one please give me a code for this.
No. What you want to do is nearly trivial. What have you tried? What happened when you tried it?

Do you know how to read the flex sensor? The readings will never change by 5000 out of a range of 0 to 1023, by the way.

Do you know how to spin the motor each direction?

Do you know how to make things happen for specific periods of time? No, not delay(). Try again.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 134
We were born naked, wet and hungry. And then things get worse!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry
I was in a hurry when I posted this. Let me repost it.
Ok.
The Flex sensor is connected to the analog Pin Via a Pull up Resistor. I get around 103 when it is straight and around 225 when it is bent. It works pretty well. (5k and 10k were in Ohms. I was not specific in last post. Sorry again).
The motors are connected to L293D and two of the inputs are given to the PWM pins in the controller. Forward and Backward are controlled by 0,1 inputs.
What I did.
Is really the basics.
I assumed a value of 150
If (analogValue > 150){
digitalWrite(m1,HIGH);
digitalWrite(m2,LOW);
Delay(1000);
}
If (analogValue <  150){
digitalWrite(m1,LOW);
digitalWrite(m2,HIGH);
Delay(1000);
}
“Do you know how to make things happen for specific periods of time?”
Without Delay? No, I don’t. Could you please let me know how to do it.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 134
We were born naked, wet and hungry. And then things get worse!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What I really want my motor to do is to rotate as the analog values drop from 225 to 103.
(I was thinking of while and do while loop. Am not sure about it).

Please suggest.

Thankyou
Regards
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50928
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Every time, the value of the flex sensor reduces by 5k I want a dc geared motor to spin for .5 sec and for every 5k increase, it must pin in anti clock wise directioni for .5 sec.
This specifies specific durations for the motors to spin.

Quote
What I really want my motor to do is to rotate as the analog values drop from 225 to 103.
This specifies conditions to start and stop the spinning.

The requirements are completely different, and non-inclusive.

Which do you really want to do? What is the purpose of spinning the motor one way or the other?

Perhaps you have chosen the wrong kind of motor. It almost seems like a servo or stepper motor would have been a better choice.
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

“Do you know how to make things happen for specific periods of time?”
Without Delay? No, I don’t. Could you please let me know how to do it.
look at blink without delay

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Full Member
***
Karma: 0
Posts: 134
We were born naked, wet and hungry. And then things get worse!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I  want my motor to rotate as the analog values drop from 225 to 103.
Stepper Motor Could have been a better choice. But I already had this geared DC motor. So I thought of making it with this motor. Is it not possible to do with with a DC motor? (Not even with While or do while)

Please Suggest

Thank You
Regards
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I  want my motor to rotate as the analog values drop from 225 to 103.
Stepper Motor Could have been a better choice. But I already had this geared DC motor. So I thought of making it with this motor. Is it not possible to do with with a DC motor? (Not even with While or do while)
Look at the motor party example

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Full Member
***
Karma: 0
Posts: 134
We were born naked, wet and hungry. And then things get worse!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Errmm.. I dont have this motor party anywhere.. Tried to google it. I found some add on packs useful for stepper motor. I dont find anything for a DC Motor. Could you please send me the link for that example

Please Suggest

Thank you
Regards
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yo probably didn't look at the most obvious place: The arduino IDE. smiley-twist
In the arduino IDE select file->examples->afmotor->examples->motorparty

I guess the code was delivered by adafruit. The doc there can be found at http://www.ladyada.net/make/mshield/

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Full Member
***
Karma: 0
Posts: 134
We were born naked, wet and hungry. And then things get worse!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah..kk
I actually checked it in the examples of IDE and I didnt find. I had to dload the file to the examples form that site. Thanks . I got it now..  smiley .. But I am still not sure If this is what I need. Let me try this and get back..

Once again.. Thanks for all the help

Regards..
Logged

Pages: [1]   Go Up
Jump to: