Update.
Fixed bug.
This commit is contained in:
@@ -16,7 +16,7 @@ void main(void)
|
||||
wiringPiSetup(); //Initialize wiringPi.
|
||||
|
||||
pinMode(ledPin, OUTPUT);//Set the pin mode
|
||||
printf("Using pin%d\n",%ledPin); //Output information on terminal
|
||||
printf("Using pin%d\n",ledPin); //Output information on terminal
|
||||
while(1){
|
||||
digitalWrite(ledPin, HIGH); //Make GPIO output HIGH level
|
||||
printf("led turned on >>>\n"); //Output information on terminal
|
||||
|
||||
@@ -21,8 +21,8 @@ int main(void)
|
||||
|
||||
wiringPiSetup(); //Initialize wiringPi.
|
||||
|
||||
pinMode(ledPin, OUTPUT); Set ledPin to output
|
||||
pinMode(buttonPin, INPUT); Set buttonPin to input
|
||||
pinMode(ledPin, OUTPUT); //Set ledPin to output
|
||||
pinMode(buttonPin, INPUT); //Set buttonPin to input
|
||||
|
||||
pullUpDnControl(buttonPin, PUD_UP); //pull up to high level
|
||||
while(1){
|
||||
|
||||
@@ -18,7 +18,7 @@ void main(void)
|
||||
wiringPiSetup(); //Initialize wiringPi.
|
||||
|
||||
for(i=0;i<ledCounts;i++){ //Set pinMode for all led pins to output
|
||||
pinMode(pins[i], OUTPUT);
|
||||
pinMode(pins[i], OUTPUT);
|
||||
}
|
||||
while(1){
|
||||
for(i=0;i<ledCounts;i++){ // move led(on) from left to right
|
||||
|
||||
@@ -9,16 +9,16 @@ import RPi.GPIO as GPIO
|
||||
import time
|
||||
import random
|
||||
|
||||
pins = {'pinRed':11, 'pinGreen':12, 'pinBlue':13} # define the pins for RGBLED
|
||||
pins = [11, 12, 13] # define the pins for R:11,G:12,B:13
|
||||
|
||||
def setup():
|
||||
global pwmRed,pwmGreen,pwmBlue
|
||||
GPIO.setmode(GPIO.BOARD) # use PHYSICAL GPIO Numbering
|
||||
GPIO.setup(pins, GPIO.OUT) # set RGBLED pins to OUTPUT mode
|
||||
GPIO.output(pins, GPIO.HIGH) # make RGBLED pins output HIGH level
|
||||
pwmRed = GPIO.PWM(pins['pinRed'], 2000) # set PWM Frequence to 2kHz
|
||||
pwmGreen = GPIO.PWM(pins['pinGreen'], 2000) # set PWM Frequence to 2kHz
|
||||
pwmBlue = GPIO.PWM(pins['pinBlue'], 2000) # set PWM Frequence to 2kHz
|
||||
pwmRed = GPIO.PWM(pins[0], 2000) # set PWM Frequence to 2kHz
|
||||
pwmGreen = GPIO.PWM(pins[1], 2000) # set PWM Frequence to 2kHz
|
||||
pwmBlue = GPIO.PWM(pins[2], 2000) # set PWM Frequence to 2kHz
|
||||
pwmRed.start(0) # set initial Duty Cycle to 0
|
||||
pwmGreen.start(0)
|
||||
pwmBlue.start(0)
|
||||
|
||||
@@ -29,9 +29,9 @@ def destroy():
|
||||
|
||||
if __name__ == '__main__': # Program entrance
|
||||
print ('Program is starting...')
|
||||
setup()
|
||||
try:
|
||||
setup()
|
||||
try:
|
||||
loop()
|
||||
except KeyboardInterrupt: # Press ctrl-c to end the program.
|
||||
destroy()
|
||||
except KeyboardInterrupt: # Press ctrl-c to end the program.
|
||||
destroy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user