Next SimpleIDE Issue: PING and 2 Servos
NWCCTV            
            
                Posts: 3,629            
            
                    So I know the Servos work and I know the PING works. However, in the following code only the Servo on Pin 14 will run but not the one on Pin 15. Helppppp!!!!
                            /*Test Ping Distance.c
Measure and display Ping))) Ultrasonic Distance Sensor distance measurements.
http://learn.parallax.com/propeller-c-simple-devices/sense-distance-ping
*/
#include "simpletools.h" // Include simpletools header
#include "ping.h" // Include ping header
#include "servo.h"
int main() // main function
{
while(1) // Repeat indefinitely
{
int cmDist = ping_cm(13); // Get cm distance from Ping)))
print("cmDist = %d\n", cmDist); // Display distance
pause(200); // Wait 1/5 second
if(cmDist <6)
{
servo_speed(14, 100); // P18 servo full speed CCW
servo_speed(15, -100); // P19 servo full speed CW
} 
else 
servo_speed(14,0);
servo_speed(15,0);
}
}
                
                            
Comments
#include "simpletools.h" // Include simpletools header #include "ping.h" // Include ping header #include "servo.h" int main() // main function { while(1) // Repeat indefinitely { int cmDist = ping_cm(13); // Get cm distance from Ping))) print("cmDist = %d\n", cmDist); // Display distance pause(200); // Wait 1/5 second if(cmDist <6) { servo_speed(14, 100); // P18 servo full speed CCW servo_speed(15, -100); // P19 servo full speed CW } else servo_speed(14,0); [COLOR="#FF0000"] servo_speed(15,0);[/COLOR] } }if(cmDist <6) { servo_speed(14, 100); // P18 servo full speed CCW servo_speed(15, -100); // P19 servo full speed CW } else { servo_speed(14,0); servo_speed(15,0); }Your original code is equivalent toif(cmDist <6) { servo_speed(14, 100); // if servo_speed(15, -100); // if } else { servo_speed(14,0); // else } servo_speed(15,0); // always