Optimized code.

Optimized code. Remove some redundant code.
This commit is contained in:
Suhayl
2019-04-11 11:16:42 +08:00
parent cd70e91d19
commit e951297ff1
3 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -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))