Need URGENT Help with Flex 2.2 and Arduino 328

Hello Friends,

I am sorry that i am posting this in the last hour, but i believe that someone here can help me out please. I am trying to convert a 2.2inch flex sensor bought from SparkFun which gives 20kOhms at normal condition to 40kohms or above after bending.

I have Arduino 328 with me which works fine.

But Unable to figure out the code or the entire construction completely.

Will someone here please help me out. I am learner here. And I have only one day to submit my final project. That only one stage is stuck to make it through.

I just need an output of 0kohms(while flex is NOT bent) to 5kohms (while flex is bent ) --anyhow. You ask me what to do and guide me, and will do.

Waiting for your replies.

Thanks.

I am very confused as to what you want/need.

Since you mention an Arduino, it sounds like you want to record the bend sensor on the Arduino, and yet you memtion you want a resistive output from 0 to 5kOhms.

If you want help, you are going to have to be more clear as to what you need.

PS: Waiting till the last minute to do a final project is never a good idea!

Hello Sweeny,

Thanks for your reply. I know it is an accident, wish I cud tell you my story, but someday later.

Well I want to replace a 0~5k Ohms pot with this 2.2 inch flex sensor using this Arduino.

Does it make any sense now?

Please Help.

An Arduino does not have a resistive output. You could possibly buy a digital potentiometer and control it from the Arduino after reading the bend sensor.

Arduino’s have either digital, or PWM outputs. With a few simple parts you can create an analog VOLTAGE output.

What exactly does the pot you want to replace do? If the pot is tied across 5 volts or less and the wiper goes to something that senses VOLTAGE you might be able to do what you want. You could create a small ADC converter using a cap and resistor (and possibly an opamp) to convert a PWM into a voltage. That voltage could then go to the device the port is controlling.

But if the pot is used to limit current (like a dimmer) than you are sunk without a digital pot.

Okay Sweeny,

(Damn you are an angel, I must say :-D)

Well just think we have a remote controlled aircraft, now i want to replace the remote control’s lever (joystick) , which controls the thrust, with that flex sensor.

That single lever-pot (joystick) has value of 0 to 5kohms … ie, while it is at normal condition, it has 0ohm and while we raise the lever it gives 5kohm of resistance.

I want to get the same behavior using this 2.2inch flex sensor.

I have already tested Arduino using flex and voltage divider (using a 10kohms at ground), but please help me out with the output please and the program as well.

I shall be gratefull.

thanks

Well Sweeny, one more additional data,

I am trying to control the flex senor, which must reduce a 4V input to 3.5V or a bit less than than.

Now, is it possible?

I am so sorry for my ill-literacy about this subject, though electronics is always been my hobby but digital electronics is kinda tough for me.

waiting for your help my friend

If it is truly a potentiometer to an RC transmitter, than the current draw on the potentiometer is very likely very small. In tech words, the transmitter’s input is high impedance. You have crossed the first hurtle.

Next, what is the voltage across the ends of the pot? If it is less or equal to the 5V your Arduino is running at, you have a chance. Your Arduino is a 5V device correct? Or is it 3.3V?

If you pass this next hurtle, than you need to google for a circuit to made a simple ADC from the PWM output, a cap and a resistor. Lets hope you don’t need the opamp as a impedance buffer to the RC TX.

Once you get the ADC circuit built, you will need to connect the bend sensor to the Arduino. This should be a very simple problem with lots on examples on the web. Lastly you will need to write a simple program to read the bend sensor and set a proportianal PWM value.

Hope you are a fast learner!

azr:
I am trying to control the flex senor, which must reduce a 4V input to 3.5V or a bit less than than.

You will need to explain this better. Is the Flex sensor being powered at 4 volts? Why the 3.5V limit? Is that the voltage limit on the current pot?

Yes Sweeny!

That potis doing the same, it is reducing the 4V into 3.5 V on full bending

And yes i am trying to give a 4V DC (Analog) which suits the Arduino, as you said.

We have Opamp ready as well.

Dont know which Cap I need to add and where now.

Well, Can I do that through programming only?

I shall connect the VIN from my RC board with one leg of flex sensor …then i shall add a 10k or 22k ohms at the other end till GRND and connect to A0

Now will program something and Map() it

Now will fix a PWM pin to get the output.

How does it sound now?

Now if it is making sense, then help me with the code please. please.

http://provideyourown.com/2011/analogwr … o-voltage/

Gives a good idea how to create a voltage from a PWM.

And yes, I have to power the Flex with 4V Dc which I am getting out of my RC.

before it was at 2.5v now I have increased after some bloody calculations :smiley:

Help!!

Looks like promising. reading and bit excited.

Thanks my friend.

Will reply here soon. Give me some time.You rock !

Time to review because the language barrier is a getting to be a problem.

You want to connect a flex sensor to an RC transmitter using an Arduino.

Flex sensor is not connected to anything else but just to the Arduino.

You are not constrained to using any funny voltages for the Flex sensor.

The Arduino is a 5V part.

The Arduino will generate a voltage in the range of A to B volts based on the flex sensor to simulate the original pot.

The voltage from the Arduino will be used to control an RC transmitter rather than the potentiometer.

Have you measured the voltage across the origianal pot? Not from one end to the wiper, but end to end?

Have you measures the range of volages from ground to the pot wiper over the full motion of the original potentiometer (A and B)?

azr:
And yes, I have to power the Flex with 4V Dc which I am getting out of my RC.

So it sounds like the Flex sensor is part of other circuitry you can change easily. But as long as the voltage swing from the Flex sensor is in the 0 to 5V range of the Arduino (It is a 5V Arduino right???) you are ok.

Okay I am following your steps now.

I connected the flex sensor 's one end with the GND of the Audrino’s and other end connected with 10kohms and connected with 5V of Audrion’s

And From that same leg of that flex (which connects with resistor) I am connecting to A3

Flex sensor is giving 20k Ohm of resistance while it is straight, and upon beningd it is giving around 40KOhm resistance.

From the RC Transmittter I have two wires, one I connected with the GND at Digital side of Audrino and other one at pin number 9

RC is giving 3.7 V ~ 4 V and I need to reduce it to control my craft.

I collected these two piecs of codes, how can I add and make it work now…

FOR PWM Output----

int pwmPin = 9;

int inPin = 3;

int val = 0;

float volt = 0;

void setup()

{

pinMode(pwmPin, OUTPUT);

}

void loop()

{

val = analogRead(inPin);

volt =(5.0 * val) / 1023;

val = 255 * (volt / 5);

analogWrite(pwmPin, val);

}

Flex Sensor Map-----

void setup()

{

// initialize serial communications

Serial.begin(9600);

}

void loop()

{

int sensor, degrees;

// read the voltage from the voltage divider (sensor plus resistor)

sensor = analogRead(0);

// convert the voltage reading to inches

// the first two numbers are the sensor values for straight (768) and bent (853)

// the second two numbers are the degree readings we’ll map that to (0 to 90 degrees)

degrees = map(sensor, 768, 853, 0, 90);

// note that the above numbers are ideal, your sensor’s values will vary

// to improve the accuracy, run the program, note your sensor’s analog values

// when it’s straight and bent, and insert those values into the above function.

// print out the result

Serial.print("analog input: ");

Serial.print(sensor,DEC);

Serial.print(" degrees: ");

Serial.println(degrees,DEC);

// pause before taking the next reading

delay(100);

}

right now the craft is flying with full throttle and uncontrolled, that means the voltage is lower than 3.5 or below 2.

can you give me a complete code please.

I am so lost

You can’t connect the digital output of the Arduino directly to the transmitter. Did you read the website I posted? You need to pick a suitable R and C value to add into the circuit. And if the transmitter needs more than a new micro amps of power, you may need an opamp to act as a voltage buffer (gain = +1.0).

azr:
can you give me a complete code please.

With this request you are dangerously close to commiting this error:

viewtopic.php?f=14&t=31656&hilit=money

We just need to pair him up with this guy …

http://www.kavistechnology.com/blog/wp- … xsmall.jpg

Problems solved !

Azr,

Was there ever a resolution?

Edit April-19-2012 - Hello?

Edit April-20-2012 - Lesson to self. Do not waste your time with other people’s homework. Invest your time with those that will truly benefit.