3.[ExternButton](#3-externbutton) for reading the value of a button connecting a GPIO pin with GND
4.[ServoMotor](#4-servomotor) for running a servomotor
## 1. ADC
# How to Use
### How to Use
1. Connect outermost pins of the potentiometer to 3V und GND on the board.
2. Connect middle pin of potentiometer to GPIO pin PC1,
3. Add ADC.c to your CMake target: ECOS_ADD_EXECUTABLE(app main.c src/ADC.c <othersources>)
3. Add ADC.cpp to your CMake target: ECOS_ADD_EXECUTABLE(app main.c src/ADC.c <othersources>)
4. Include ADC.h where you want to use the ADC.
5. Run adc_init() once before first usage.
6. Every call to adc_get(11) will now return an unsiged integer between 0 and 4096 telling you the current position of the potetiometer.
# Possible edits
In total 16 of the GPIO pins are connected to the ADC. If PC1 is already in use in your design or you have two potentiometers, you can use different pins as ADC. For this, uncomment the respective line in the init function and call adc_get() with the respective channel ID.
### Possible edits
In total 16 of the GPIO pins are connected to the ADC. If PC1 is already in use in your design or you have two potentiometers, you can use different pins as ADC. For this, uncomment the respective lines in ADC.cpp file in the init function and call adc_get() with the respective channel ID.
Connections are as follows:
- ADC Channel 0 <> GPIO PA0
...
...
@@ -39,6 +41,14 @@ Connections are as follows:
- ADC Channel 15 <> GPIO PC5
## 2. DCMotor
### How to Use
1. Connect VCC and GND pin of the motordriver to 5V and GND on the board respectifly.
2. Connect R_EN and L_EN to PC4 and PC5.
3. Connect RPWM to PB0 and LPWM to PB1.
3. Add DCMotor.cpp to your CMake target: ECOS_ADD_EXECUTABLE(app main.c src/DCMotor.c <othersources>)
4. Include DCMotor.h where you want to control the motor.
5. Run dc_init() once before first usage.
6. Controll the motor by calling dc_set(<DC_RIGHT|DC_LEFT>, <0...255>)