Combining 360 degree continuous motor and force sensors

Hello,
I am using 2 FT90R continuous motors and 5 force sensors.
I require the code to make the motors rotate together until any of the force sensors detect 20N being applied to them however I am unsure how to do this.

I have the following code where one force sensor controls the speed and direction of rotation but don't know how to get from this to what I need the code to do.

#include <Servo.h>

Servo servo;
int sensorvalue =0;

void setup() {
pinMode(A0,INPUT); //force sensor value input
pinMode(3,OUTPUT); //PWM output to servo
servo.attach(3); //telling where signal pin of servo attached(must be a PWM pin)
}

void loop() {
sensorvalue = analogRead(A0); //read analog value from sensor
servo.write(sensorvalue/6); //set servo position based on ADC result
}

Any help would be greatly appreciated.

You will need to calibrate the FSR so that you know what 20N is in terms of the analogRead input.
That may be challenging as the FSRs are not linear nor are they known for repeatability.

Then use if statements to determine when to turn the motors on to speed or off.

What does the code do? Does it do what you want that code to do?

Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
code tags new

I don't think that way of running the motor will work. That's used for real servo moving 0 to 180 degrees.
I would use digitalWrite( 3, pwmValue);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.