hello,
i have a problem with my code. I created a method to control servo motor, and i want to use this method in Main()
but if i write “PWM servo = new PWM…” in my servo method there are a error, and if i write this in Main(), there are an error in the Servo method because the pin don’t exist.
So could you tell me, please, how use the servo pin when i declared it in Main() . I tried to write this : servoMethod(servoPin) {…} but i don’t work.
i hope you understand my problem
my “part” of code :
public static void Servo(int pos)
{
PWM servoBase = new PWM((PWM.Pin)FEZ_Pin.PWM.Di9);
if (pos == 0)
{
servoBase.SetPulse(20 * 1000 * 1000, 1250 * 1000);
}
else if (pos == 90)
{
servoBase.SetPulse(20 * 1000 * 1000, 1500 * 1000);
}
else if (pos == 180)
{
servoBase.SetPulse(20 * 1000 * 1000, 1750 * 1000);
}
else { }}
public static void Main()
{
bool Play = true;
while (Play==true)
{
Servo(0);
Thread.Sleep(1000);
Servo(180);
Thread.Sleep(1000);
Servo(90);
Thread.Sleep(1000);
}
}
i solved my problem with :
"public static void Servo(int pos,PWM servoBase)"
thx for help