Hi,
I have two brand new RedBoard Artemis. I am trying to control a servo using the Servo.h library.
I have two servos: SG90 (http://www.ee.ic.ac.uk/pcheung/teaching … asheet.pdf) and MG966R (https://www.electronicoscaldas.com/data … er-Pro.pdf). I have tested both servos using a servo tester (https://www.amazon.com/gp/product/B06WV … UTF8&psc=1) and I can confirm both are working.
I have made the following connections:
RedBoard +5V → Servo red cable
RebBoard GND → Servo brown cable
RedBoard 8 → Servo yellow cable
I know it is now recommended to power the servo directly from the board, but for testing purposes, that should be OK.
In the Arduino IDE, I have compiled and uploaded the example code from SparkFun (Example1_BasicServo). Compilation and upload are going without issue.
/*
Author: Nathan Seidle
SparkFun Electronics
Created: August 18th, 2019
Purchasing from SparkFun helps write code like this and helps us
release products open source so that we can help each other learn: https://www.sparkfun.com/artemis
This example demonstrates the control of a servo on pin 8 on the RedBoard Artemis. Any PWM
pin can control a servo.
Hardware Connections:
Load this code
Connect a Servo to pin 18:
Red Wire -> 3.3V or 5V
Black Wire -> GND
Signal (Yellow or White) -> 8
The servo will rotate back and forth.
*/
/*
// This file is subject to the terms and conditions defined in
// file 'LICENSE.md', which is part of this source code package.
*/
#include <Servo.h>
Servo myServo;
int pos = 0;
void setup()
{
Serial.begin(9600);
Serial.println("SparkFun Servo Example");
myServo.attach(8);
}
void loop()
{
//Sweep
for (pos = 0; pos <= 180; pos++) { // goes from 0 degrees to 180 degrees
myServo.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos--) { // goes from 180 degrees to 0 degrees
myServo.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
}
The servo does not budge.
I have tried different pins for the PWM (2,3,4,5,6,7,8,9,10), still no result. I have tried both boards, same (non) result.
I can blink the LED and use the Fade example code, so the board seem to be working.
What am I doing wrong?