Example code that solves the challenges.

To access the full video please subscribe to FLLCasts.com
- #836
- 09 Apr 2018
Create a program to greet you by your name
print("Hello, mr/mrs Teacher")
Create a program to start the lights with brightness equal to your age
from time import sleep # we need sleep function from time library import RPi.GPIO as GPIO # GPIO library to control pins GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) # BCM means we will use GPIO numbers, not pin numbers frontLightsPin = 18 # GPIO 18 frequency = 50 frequency = 50 GPIO.setup(frontLightsPin, GPIO.OUT) # set GPIO 18 in output mode, the led is there front_lights = GPIO.PWM(frontLightsPin, frequency) # PWM = pulse width modulation with 50Hz (blinks per second) max_light = 32 front_lights.start(max_light) sleep(0.200) front_lights.stop() GPIO.cleanup()
Change the program to start the lights with brightness three times your age
from time import sleep # we need sleep function from time library import RPi.GPIO as GPIO # GPIO library to control pins GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) # BCM means we will use GPIO numbers, not pin numbers frontLightsPin = 18 # GPIO 18 frequency = 50 GPIO.setup(frontLightsPin, GPIO.OUT) # set GPIO 18 in output mode, the led is there front_lights = GPIO.PWM(frontLightsPin, frequency) # PWM = pulse width modulation with 50Hz (blinks per second) age = 32 max_light = age * 3 front_lights.start(max_light) sleep(0.200) # dot front_lights.stop() GPIO.cleanup()
Create a program that blinks the LED as letter "R" in morse code
from time import sleep # we need sleep function from time library import RPi.GPIO as GPIO # GPIO library to control pins GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) # BCM means we will use GPIO numbers, not pin numbers frontLightsPin = 18 # GPIO 18 frequency = 50 GPIO.setup(frontLightsPin, GPIO.OUT) # set GPIO 18 in output mode, the led is there front_lights = GPIO.PWM(frontLightsPin, frequency) # PWM = pulse width modulation with 50Hz (blinks per second) age = 32 max_light = age * 3 front_lights.start(max_light) sleep(0.200) # dot front_lights.stop() sleep(0.200) # pause front_lights.start(max_light) sleep(3 * 0.200) # dash front_lights.stop() sleep(0.200) # pause front_lights.start(max_light) sleep(0.200) # dot front_lights.stop() sleep(0.200) # pause GPIO.cleanup()
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

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

Create Python programs controlling the car LEDs
Here we have detailed explaination what we expect from you. Bonus: how to do copy-paste within nano.
- 2
- 0
- 5
- 3d_rotation 0