Herunterladen Inhalt Inhalt Diese Seite drucken

SunFounder Da Vinci Kit Bedienungsanleitung Seite 47

Für den raspberry pi 4 modell b, 3 modell a +, 3 modell b +, 3 modell b, 2 modell b, 1 modell b +, 1 modell a +, zero w and zero
Inhaltsverzeichnis

Werbung

Code
#include
<wiringPi.h>
#include
<softPwm.h>
#include
<stdio.h>
#define uchar unsigned char
#define LedPinRed
#define LedPinGreen
#define LedPinBlue
void
ledInit(void){
softPwmCreate(LedPinRed,
softPwmCreate(LedPinGreen,0, 100);
softPwmCreate(LedPinBlue, 0, 100);
}
void
ledColorSet(uchar r_val, uchar g_val, uchar b_val){
softPwmWrite(LedPinRed,
softPwmWrite(LedPinGreen, g_val);
softPwmWrite(LedPinBlue,
}
int
main(void){
if(wiringPiSetup()
screen
printf("setup wiringPi failed
return
1;
}
ledInit();
while(1){
printf("Red\n");
ledColorSet(0xff,0x00,0x00);
delay(500);
printf("Green\n");
ledColorSet(0x00,0xff,0x00);
delay(500);
printf("Blue\n");
ledColorSet(0x00,0x00,0xff);
delay(500);
printf("Yellow\n");
ledColorSet(0xff,0xff,0x00);
delay(500);
printf("Purple\n");
ledColorSet(0xff,0x00,0xff);
delay(500);
printf("Cyan\n");
ledColorSet(0xc0,0xff,0x3e);
delay(500);
}
return
0;
}
Code Erklärung
#include
<softPwm.h>
Bibliothek zur Realisierung der PWM-Funktion der Software.
1.7. 1 Ausgabe
0
1
2
0, 100);
r_val);
b_val);
==
-1){
//when initialize wiring failed, printf messageto
!");
//red
//green
//blue
//yellow
//purple
//cyan
SunFounder Da Vinci Kit
43

Werbung

Inhaltsverzeichnis
loading

Verwandte Produkte für SunFounder Da Vinci Kit

Diese Anleitung auch für:

Davinci-kit-for-raspberry-pi

Inhaltsverzeichnis