1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/usr/bin/env python # -*- coding: utf-8 -*- import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) # need to set up every channel which are using as an input or an output GPIO.setup(11, GPIO.OUT) while True: GPIO.output(11, GPIO.HIGH) time.sleep(1) GPIO.output(11, GPIO.LOW) time.sleep(1) |
1 | sudo python led.py |
1 2 3 4 5 6 7 8 9 10 11 | #include <wiringPi.h> main () { wiringPiSetup () ; pinMode (0, OUTPUT) ; for (;;) { digitalWrite (0, HIGH) ; delay (500) ; digitalWrite (0, LOW) ; delay (500) ; } } |
1 | gcc -Wall -o blink blink.c -lwiringPi |
1 | sudo ./blink |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <bcm2835.h> // Blinks on RPi Plug P1 pin 11 (which is GPIO pin 17) #define PIN RPI_GPIO_P1_11 int main(int argc, char **argv) { if (!bcm2835_init()) return 1; // Set the pin to be an output bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP); // Blink while (1) { bcm2835_gpio_write(PIN, HIGH); bcm2835_delay(100); bcm2835_gpio_write(PIN, LOW); bcm2835_delay(100); } bcm2835_close(); return 0; } |
1 | gcc -o blink blink.c -l bcm2835 |
1 | sudo ./blink |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |