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);
}