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.
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.
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).
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.
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.
FelixFelicis:
“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.
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)
FelixFelicis:
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)
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
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.. .. But I am still not sure If this is what I need. Let me try this and get back..