2

我在 python 中有一个 GPIO 程序 .. 任何人都可以帮助我让等效的 C 或 C++ 程序在树莓派上运行 ..

蟒蛇代码是

import RPi.GPIO as GPIO  
import time  
# blinking function  
def blink(pin):  
    GPIO.output(pin,GPIO.HIGH)  
    time.sleep(1)  
    GPIO.output(pin,GPIO.LOW)  
    time.sleep(1)  
    return  
# to use Raspberry Pi board pin numbers  
GPIO.setmode(GPIO.BOARD)  
# set up GPIO output channel  
GPIO.setup(11, GPIO.OUT)  
# blink GPIO17 50 times  
for i in range(0,50):  
        blink(11)  
GPIO.cleanup()

提前致谢!:)

4

1 回答 1

2
#include <header.h> // which contatining some delay function
void blink(int pin)
{ 
    //Program the pin (which GPIO) to  high
    //delay function
    //Program the pin (which GPIO) to low
    //delay
    return 0;
}
main()
{
// to use Raspberry Pi board pin numbers  
GPIO.setmode(GPIO.BOARD)  //check this fun def and find out what it is doing and code it accordingly

// set up GPIO 11 as output channel  

// blink GPIO11 50 times  
for(i=0;i<50;i++)  
        blink(11);

GPIO.cleanup() ////check this fun def and find out what it is doing and code it
于 2013-04-05T09:30:18.723 回答