So I'm trying to run a servo and an OLED screen at the same time. But every time the OLED draws a bitmap the servo stutters. What gives? Can the Nano only power one or the other? Or could it be a problem with the code?
For anyone interested in the code, it reads as follows:
void loop() {
currentMillis = millis();
servoSweep();
screenSweep(); }
void servoSweep() {
if (currentMillis - previousServoMillis >= servoInterval)
{ previousServoMillis += servoInterval; servoPosition = servoPosition + servoDegrees; }
if ((servoPosition >= servoMaxDegrees) || (servoPosition <= servoMinDegrees))
{ servoDegrees = - servoDegrees; servoPosition = servoPosition + servoDegrees; }
myservo.write(servoPosition); }
void screenSweep() {
if (currentMillis - previousMillis == intervalOne) { display.drawBitmap( 0, 0, one, 128, 64, 1); }
if (currentMillis - previousMillis == intervalTwo) { display.drawBitmap( 0, 0, two, 128, 64, 1); }
if (currentMillis - previousMillis == intervalThree) { previousMillis = currentMillis; }
}