Pinguino Forum
Controll a servo with a potentiometer - Printable Version

+- Pinguino Forum (http://forum.pinguino.cc)
+-- Forum: Software (http://forum.pinguino.cc/forumdisplay.php?fid=7)
+--- Forum: Syntax & Programs (http://forum.pinguino.cc/forumdisplay.php?fid=19)
+--- Thread: Controll a servo with a potentiometer (/showthread.php?tid=4845)

Pages: 1 2 3


Controll a servo with a potentiometer - SGTheDreamer - 29-05-2016

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


RE: Controll a servo with a potentiometer - derf158 - 30-05-2016

which pinguino IDE are you using?

fred


RE: Controll a servo with a potentiometer - SGTheDreamer - 30-05-2016

(30-05-2016, 01:01 AM)derf158 Wrote: which pinguino IDE are you using?

fred

right now I have 12 version, I could install v11 too but It seems its not working too. 

In other page says it will work with X.3 Version of the IDE, but I could not install it good. The IDE doesn't upload the program to the Pinguino.


RE: Controll a servo with a potentiometer - derf158 - 30-05-2016

what value pot are you using 10k?

fred


RE: Controll a servo with a potentiometer - SGTheDreamer - 30-05-2016

(30-05-2016, 03:36 AM)derf158 Wrote: what value pot are you using 10k?

fred

Yes.


RE: Controll a servo with a potentiometer - derf158 - 30-05-2016

i will try this on my v12 tomorrow


RE: Controll a servo with a potentiometer - SGTheDreamer - 30-05-2016

(30-05-2016, 04:10 AM)derf158 Wrote: i will try this on my v12 tomorrow

Thanks dude, If it works for u , let me know how. :Big Grin I ll be so grateful. 

Nice day or night.


RE: Controll a servo with a potentiometer - derf158 - 30-05-2016

i tried the PDE you posted and it worked i have attached a zip file of my p8 folder rename yours and insert mine it should work.


RE: Controll a servo with a potentiometer - SGTheDreamer - 30-05-2016

Bro I am so sad, It shoud work too but its the same, the servo moves without sense, but I ill try reinstalling it .
Dude, can u send me a zip file whit the v12 carpet of your pinguino Big Grin or a page where i see the steps to intall from zero. Maybe I did something wrong in that part.

- Or a easy pack for that versión if u have it...(easy pack - no installating required(just like portable))
Or maybe a picture, of your conexionsSmile, I need to try everything before give up :c
Good day! Smile


RE: Controll a servo with a potentiometer - derf158 - 30-05-2016

are you running windows or linux?