A servo can draw a significant amount of power. Perhaps that is what is causing problems? Do you have a hefty 5-6V power supply for the servos?
I have used two microservos which I don't think are using that much power. But even without them attached physically, the program won't work as intended..
Servos use timers. PWM users timers. There are not enough timers to go around, so using servos means sacrificing PWM capabilities, on some pins.
The first to go are the ones on pins 9 and 10. Use some other PWM pins for your LED.
I am not sure I understand how PWM uses timers and there is not enough timers to go around. How is that? but I will follow your advice and use other PWM pins for the LED.
You update sensorValue just once per loop(), because it's outside the while(runWeight) {} block. I don't see how you can get out of that while() cycle.
My intention was that once there is no weight on the scale this will happen
else
{
//servo2.write(servo2Pos = 80);
green(); // when nothing is on the weight, the RGB LED turns green again
//delay(500);
runWeight = false;
}
and runWeight will be set to false, therefore breaking the while cycle. But this might not be the best solution..!?
Thanks for your replies guys
Now I will try out some of the changes and keep you posted