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
30-05-2016, 01:01 AM,
#2
RE: Controll a servo with a potentiometer
which pinguino IDE are you using?

fred
Reply
30-05-2016, 02:52 AM, (This post was last modified: 30-05-2016, 03:00 AM by SGTheDreamer.)
#3
Tongue  RE: Controll a servo with a potentiometer
(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.
Reply
30-05-2016, 03:36 AM,
#4
RE: Controll a servo with a potentiometer
what value pot are you using 10k?

fred
Reply
30-05-2016, 04:04 AM,
#5
RE: Controll a servo with a potentiometer
(30-05-2016, 03:36 AM)derf158 Wrote: what value pot are you using 10k?

fred

Yes.
Reply
30-05-2016, 04:10 AM,
#6
RE: Controll a servo with a potentiometer
i will try this on my v12 tomorrow
Reply
30-05-2016, 04:30 AM,
#7
RE: Controll a servo with a potentiometer
(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.
Reply
30-05-2016, 04:02 PM,
#8
RE: Controll a servo with a potentiometer
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.


Attached Files
.zip   p8.zip (Size: 488.09 KB / Downloads: 8)
Reply
30-05-2016, 04:53 PM, (This post was last modified: 30-05-2016, 05:27 PM by SGTheDreamer.)
#9
RE: Controll a servo with a potentiometer
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
Reply
30-05-2016, 09:20 PM,
#10
RE: Controll a servo with a potentiometer
are you running windows or linux?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)