// Trying to get Servo motors working
// on a Raspberry Pi Pico in Wokwi simulation
// in Arduino mode.
//
// The default "Servo" library uses the programmable
// hardware PIO. That has to be simulated by
// Wokwi. The Servo library uses the PIO in such
// a way that the simulation is too slow.
//
// The "107-Arduino-Servo-RP2040" seems to work better
// in Wokwi simulation.
// https://github.com/107-systems/107-Arduino-Servo-RP2040
// The library did no longer compile, so the library
// files have been uploaded to this project and adapted
// (only the includes are fixed).
// The example below is from the library with a few changes.
//
// Conclusion:
// I don't know if it works. Why do I have to set the
// pulse from 500 to 2400 ? It should be 1000 to 2000 us ?
//
// 8 September 2024
/**
* This software is distributed under the terms of the MIT License.
* Copyright (c) 2023 LXRobotics.
* Author: Alexander Entinger <[email protected]>
* Contributors: https://github.com/107-systems/107-Arduino-Servo-RP2040/graphs/contributors.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include "107-Arduino-Servo-RP2040.h"
/**************************************************************************************
* GLOBAL VARIABLES
**************************************************************************************/
static _107_::Servo servo_0, servo_1, servo_2, servo_3;
/**************************************************************************************
* SETUP/LOOP
**************************************************************************************/
void setup()
{
Serial.begin(115200);
while (!Serial) { }
servo_0.attach(12,1000,2000); // test
servo_1.attach(13,500,2400); // this works ?
servo_2.attach(14,500,2400);
servo_3.attach(15,500,2400);
}
void loop()
{
servo_0.write(0);
servo_1.write(0);
servo_2.write(0);
servo_3.write(0);
delay(800);
servo_0.write(180);
servo_1.write(180);
servo_2.write(180);
servo_3.write(180);
delay(800);
}