Hardware Configuration File
This file defines all the hardware in a robot and the pin assignments of the motors, sensors, speakers, and displays.
Because most of our robots use the Cytron board, the pins are standardized for most of our kits.
Using a configuration file has tradeoffs. The pros is that it allows you to change a single file when you change the wiring in your robot. All the example programs that use the config file will be automatically updated.
The disadvantage is that it makes your programs a little more abstract. New users will take some time to learn how to see how the configuration file is used to map a variable to the underlying hardware pins.
## Sample Config File
All of the hardware pins should be defined in this file.
1 2 3 |
|
Note
Make sure there are no spaces in front of the variable names.
Now in your main code you must do the following:
- Ddd the
import config
(without the .py) - place the string
config.
in front of each variable.
```python import config
# Get the data from the config file NUMBER_PIXELS = config.NUMBER_PIXELS NEOPIXEL_PIN = config.NEOPIXEL_PIN ```
By placing the config
in front of the variable name, you
tell the Python interpreter to read the variable from that file.
Standard NeoPixel Blink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|