
Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео
- #870
- 04 May 2018
Car stays and starts moving with а button press
#Define PWM functions forward = GPIO.PWM(forwardPin, frequency) backward = GPIO.PWM(backwardPin, frequency) left = GPIO.PWM(leftPin, frequency) right = GPIO.PWM(rightPin, frequency) # initialize in stopped position. Helps to avoid problems forward.stop() backward.stop() left.stop() right.stop() while GPIO.input(buttonPin) == False: # while is a loop until a condition becomes not True; 'until pressed' in this case sleep(0.010) #eof while not pressed forward.start(100) # full speed ahead sleep(3) right.start(100) # hard turn right forward.stop() # breaks! backward.start(100) # full reverse sleep(1) right.stop() # release steering backward.stop() # stop the car # we purposely do not close the GPIO, as that breaks communication with the BlueTooth app # GPIO.cleanup()
Button control - one press to start, second press to reverse, third press to stop
#Define PWM functions forward = GPIO.PWM(forwardPin, frequency) backward = GPIO.PWM(backwardPin, frequency) left = GPIO.PWM(leftPin, frequency) right = GPIO.PWM(rightPin, frequency) # initialize in stopped position. Helps to avoid problems forward.stop() backward.stop() left.stop() right.stop() while GPIO.input(buttonPin) == False: # while is a loop until a condition becomes not True; 'until pressed' in this case sleep(0.010) #eof while not pressed while GPIO.input(buttonPin) == True: # 'until released' in this case sleep(0.010) #eof while pressed forward.start(100) # full speed ahead while GPIO.input(buttonPin) == False: # while is a loop until a condition becomes not True; 'until pressed' in this case sleep(0.010) #eof while not pressed while GPIO.input(buttonPin) == True: # 'until released' in this case sleep(0.010) #eof while pressed forward.stop() # breaks! backward.start(100) # full reverse while GPIO.input(buttonPin) == False: # while is a loop until a condition becomes not True; 'until pressed' in this case sleep(0.010) #eof while not pressed while GPIO.input(buttonPin) == True: # 'until released' in this case sleep(0.010) #eof while pressed forward.stop() # breaks! backward.stop() # stop the car # we purposely do not close the GPIO, as that breaks communication with the BlueTooth app # GPIO.cleanup()
Car moves in a square shape
#Define PWM functions forward = GPIO.PWM(forwardPin, frequency) backward = GPIO.PWM(backwardPin, frequency) left = GPIO.PWM(leftPin, frequency) right = GPIO.PWM(rightPin, frequency) # initialize in stopped position. Helps to avoid problems forward.stop() backward.stop() left.stop() right.stop() for i in range(4): left.start(100) forward.start(100) # steer a while sleep(0.5) left.stop() # no steering, go straight sleep(1) #eof for 4 times forward.stop() # fully stop the car # we purposely do not close the GPIO, as that breaks communication with the BlueTooth app # GPIO.cleanup()
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.

Perfect STEM course. Module 1 - Smart Car with Raspberry PI
Disassemble a remote control car. Change the brain of the car with a smart computer like Raspberry Pi. Build a smart device with artificial intelligence that you could control from your phone and that could freely navigate itself in the real world and on the Internet. Use your hands. Develop programs for your robot and your phone. Be curious and invent.
The perfect course lives up to its name. You move through the content, we check it and return feedback to you.
In the end, you should be able to better understand how to program and design smart devices that would make the world a better place. For everybody age 12+, 16+, 21+, 35+, etc. The hardware costs about 150$. It changes through the years so it might take some time for you to find it as Raspberry PI, motor drivers, power banks and h-bridges.. they change. Note that the course was designed to be led by a teacher with a decent knowledge in embedded hardware and software. This, on the other hand should not stop you, if you are curious.
- 118
- 42:47
- 136

Execute Python program about car motors from the computer
Before you start your car, make sure that everything runs as you expect. We will do that by putting the car on a stand so that when we start to motors, the car is not moving.
- 3
- 0
- 1
- 3d_rotation 0