Optimized code.
Optimized code. Remove some redundant code.
This commit is contained in:
@@ -43,7 +43,7 @@ void motor(int ADC){
|
||||
digitalWrite(motorPin2,LOW);
|
||||
printf("Motor Stop...\n");
|
||||
}
|
||||
softPwmWrite(enablePin,map(abs(value),0,128,0,255));
|
||||
softPwmWrite(enablePin,map(abs(value),0,128,0,100));
|
||||
printf("The PWM duty cycle is %d%%\n",abs(value)*100/127);//print the PMW duty cycle
|
||||
}
|
||||
int main(void){
|
||||
|
||||
@@ -23,7 +23,7 @@ def loop():
|
||||
GPIO.output(pin, GPIO.LOW)
|
||||
time.sleep(0.1)
|
||||
GPIO.output(pin, GPIO.HIGH)
|
||||
for pin in ledPins[10:0:-1]: #make led on from right to left
|
||||
for pin in ledPins[::-1]: #make led on from right to left
|
||||
GPIO.output(pin, GPIO.LOW)
|
||||
time.sleep(0.1)
|
||||
GPIO.output(pin, GPIO.HIGH)
|
||||
|
||||
@@ -40,7 +40,6 @@ def setup():
|
||||
GPIO.setup(echoPin, GPIO.IN) #
|
||||
|
||||
def loop():
|
||||
GPIO.setup(11,GPIO.IN)
|
||||
while(True):
|
||||
distance = getSonar()
|
||||
print ("The distance is : %.2f cm"%(distance))
|
||||
|
||||
Reference in New Issue
Block a user