Pages: [1]   Go Down
Author Topic: RGB & Servo Sliders via Python  (Read 1072 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys,

I'm just getting started on the whole Arduino thing and I've hit a wall. I've modified code found here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267104041
What I am hoping for is to have 3 sliders for R, G & B, and a fourth that controls the servo.

The setup is fairly simple: pin 9, 10 and 11 are R, G and B respectively. Pin 3 is the servo.

The problem in a nutshell:
If I comment out: "servoMain.attach(servoPin);", the RGB sliders work fine.
If i leave this code in, the servo slider works fine and the B slider works fine, but the others play up.
(Moving them simply switches them to full value of that colour, and on the R slider, it also is sending some weirdness to the servo)

If anyone has any pointers, or any pointers in general about my approach and why it's flawed, please, I'd love to hear them.

Kind Regards,
Lachlan

Sourcecode:

serialRGB.ino
http://pastebin.com/tVADQPqQ

gui.py
http://pastebin.com/iWz0LBNY
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are a number of timers available on the Arduino. Servos and PWM both use timers.

One thing that you do NOT need to do is use a PWM for the servo pin.

Try connecting the LEDs to 3, 5, and 6, and the servo to some non-PWM pin.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks heaps!

I gave that a shot and i'm still not having any luck... You're right though, I don't need to be using a PWM pin for the servo... thats a good start
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pastebin is blocked for me. Please attach you code to a post directly.

Attaching one servo disables PWM on two pins. So, there should still be 4 PWM pins available. 9 and 10 are the first to go. So, 3. 5. 6. and 11 should still function.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ahh look at you! you're awesome!
that was the trick... smiley-grin

so going forward, is there anything like that i need to know? what are the maximum number of servos I can attach/how to i scale this to deal with 3 servos? 10?
Logged

Pages: [1]   Go Up
Jump to: