Hallo,
ich befürchte, dass es hier im Forum keine Person gibt, die fähig oder willens ist mir zu helfen.
Ich habe mit Hilfe anderer informationsquellen eine einfache Lösung gefunden:
C
/*
============================================================================
Name : SG90.c
Author : k.str
Version :
Copyright : Your copyright notice
Description : Runs a MicroServo SG90 on a Raspberry0 w
gpio pin : 18
IDE : Eclipse IDE for C/C++ Developers (includes Incubating components)
Version: 2022-03 (4.23.0)
Build id: 20220310-1457
OS: Windows 10, v.10.0, x86_64 / win32
Java vendor: Eclipse Adoptium
Java runtime version: 17.0.2+8
Java version: 17.0.2
Compile : Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/SG90.d" -MT"src/SG90.o" -o "src/SG90.o" "../src/SG90.c"
Linking : Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -o "SG90" ./src/SG90.o -lpigpio
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <pigpio.h>
#include <unistd.h>
#define pwmGPIO 18
unsigned pulseWidth;
int main(void) {
if(gpioInitialise()!=gpioVersion())
{
printf("error initializing pigpio\n");
return EXIT_FAILURE;
}
for(pulseWidth =500; pulseWidth<=2500; pulseWidth=pulseWidth+5) // bewege ab 0° bis 180°
{
gpioServo(pwmGPIO, pulseWidth); // bewege um 5 Pulsweiten
usleep(50000); // warte 50 Millisekunden
}
for(pulseWidth=2500; pulseWidth>=500; pulseWidth=pulseWidth-5) // bewege zuueck
{
gpioServo(pwmGPIO, pulseWidth);
usleep(50000);
}
gpioTerminate();
return EXIT_SUCCESS;
}
Display More
Das Programm muß mit root Privilegien ausgeführt werden.