but i want to set pid controller for motors,
i tried PID_v1.h but i couldnt set output pin to motors
The output is not a pin. It is a value that is to be written to a pin. But, since we can't see your code, we can't guess what your inputs and outputs are, so we can't guess how you should be using output. Probably as a speed value, but, who knows?
also i tried
analogWrite(AF_DCMotor Motor1(),Output);
So, you tried to pass a new instance of the AF_DCMotor class as the pin number. I'm not at all surprised that that didn't work.
PaulS:
That is not defining any pins.
The output is not a pin. It is a value that is to be written to a pin. But, since we can't see your code, we can't guess what your inputs and outputs are, so we can't guess how you should be using output. Probably as a speed value, but, who knows?
So, you tried to pass a new instance of the AF_DCMotor class as the pin number. I'm not at all surprised that that didn't work.
If you can't be bothered to explain what "this one" means, and post a link properly, I can't be bothered to cut and paste.
Homework is not supposed to be left until the night before it is due.
Sure it does. Motor1() is not a function that returns a pin number.
You have the motors attached to a shield. The shield hard-wires the motor #1 to some pins. The shield hard-wires the motor #2 to some pins. You have to figure out which pins those are, and which one of the two pins controls the speed of the motor. It is that pin that you use in the call to analogWrite().
Input = DistanceSensor.ping_cm();
Call the function, saving the result in some variable. Print the variable. Call the function again, and get some other distance. Use that, without a clue what it is. Why?
myPID.Compute();
This is going to use the set point (10) and the input (some distance) to compute a correction factor. What, exactly, are you going to correct with that? There is no correlation between distance and the speed of the motor.
But you elected to keep the unknown changes to yourself. Well, I guess we'll be keeping future answers to ourselves.
What, exactly, it is you are expecting the PID system to control? Typically, PID is used for things like holding a constant temperature, where the set point is the temperature to maintain, the input is the current temperature, and the output is a correction factor, positive or negative, that is used to drive a heater (when negative) or a cooler (when positive).
Your set point is a constant (what does it represent?) Your input is a distance. What do you think you will do with the correction factor? Typically, that would be used to steer closer towards, or farther away from, a wall that you are trying to keep a constant distance from. But, that output would be mapped to servo angle and used to drive a steering servo.
Why did you choose to have PID be part of your program, and what are you trying to accomplish with it?
PaulS:
What, exactly, it is you are expecting the PID system to control?
PaulS i want to make wall following robot and i use adafruit motor speed controller i think motors have to work correlated but i couldnt do this in my code.
i wrote if block for it but i couldnt do it