The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 864 - File: showthread.php PHP 7.2.25 (Linux)
File Line Function
/showthread.php 864 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controll a servo with a potentiometer
29-05-2016, 07:23 PM,
#1
Controll a servo with a potentiometer
Hey guys.

Its really important for me If someone knows the solution to this.

I try to controll a servo with a variable resistor in pinguino with a 18f4550. If Resistence =0, Move servo to 0 degress, if resistence máxValue , put servo on 180 degrees. That's all I need to do.

I put this code but it doesn't work....
I put it on Arduino, and works great but in pinguino just move without sense. :Sad And I need for my project in Pinguino only.

int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

void setup()
{
servo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
servo.write(9, val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

I ll be really happy I you could help me in something. Smile
Reply


Messages In This Thread
Controll a servo with a potentiometer - by SGTheDreamer - 29-05-2016, 07:23 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)