Hallo,
bezüglich Raspberry Pi 3 und GPIO bin ich ein Neueinsteiger und versuche mich momentan an einem ersten Beispiel: Eine LED per Raspberry Pi 3 zum Blinken zu bringen.
Ich folgte dabei dieser Beschreibung:
In this experiment, connect a 220Ω resistor to the anode of the LED and then connect the resistor to 3.3 V power source, and connect the cathode of the LED to GPIO0 (See Raspberry Pi Pin Number Introduction). Write 1 to GPIO0, and the LED will not light up; write 0 to GPIO0, and then the LED will blink according to principle mentioned previously.
Schaltplan siehe Anhang.
Was sich mit leider nicht erschließen will, ist die Tatsache, dass ich auf dem GPIO-Pin eine 1 senden muss, damit die LED ausgeht. Und andersherum muss ich eine 0 senden, damit die LED leuchtet. Vom Prinzip hätte ich das eher umgekehrt erwartet. Wo liegt hier mein Denkfehler. Für Hinweise bin ich sehr dankbar!
Hier der Quellcode:
#include <wiringPi.h>
#include <stdio.h>
#define LedPin 0
int main(void)
{
if(wiringPiSetup() == -1){ //when initialize wiring failed,print messageto screen
printf("setup wiringPi failed !");
return 1;
}
printf("linker LedPin : GPIO %d(wiringPi pin)\n",LedPin); //when initialize wiring successfully,print message to screen
pinMode(LedPin, OUTPUT);
while(1){
digitalWrite(LedPin, LOW); //led on
printf("led on...\n");
delay(500);
digitalWrite(LedPin, HIGH); //led off
printf("...led off\n");
delay(500);
}
return 0;
}
Gruß, PiPower