diff --git a/CMakeLists.txt b/CMakeLists.txt index 7171dd2..63a3def 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ target_include_directories(Mon_Projet PRIVATE Mon_Projet_ULD_API/inc/) target_link_libraries(Mon_Projet hardware_i2c hardware_uart + hardware_pwm pico_stdlib pico_multicore ) diff --git a/main.c b/main.c index f79df64..a337170 100644 --- a/main.c +++ b/main.c @@ -1,16 +1,77 @@ -/***** + /***** * Copyright (c) 2023 - Poivron Robotique * * SPDX-License-Identifier: BSD-3-Clause */ #include "pico/stdlib.h" +#include "hardware/pwm.h" #include -void main(void) +#define LED_VERTE 25 +#define PIN_VITESSE_M1 2 +#define PIN_SENS_A_M1 0 +#define PIN_SENS_B_M1 1 +int M1_INITIALISE() { - stdio_init_all(); - while(1){ - printf("Exemple\n"); - sleep_ms(1000); - } + gpio_init(PIN_VITESSE_M1); + gpio_init(PIN_SENS_A_M1); + gpio_init(PIN_SENS_B_M1); + + gpio_set_dir(PIN_VITESSE_M1, GPIO_OUT); + gpio_set_dir(PIN_SENS_A_M1, GPIO_OUT); + gpio_set_dir(PIN_SENS_B_M1, GPIO_OUT); + } + +int M1_AVANCE() +{ + + gpio_put(PIN_VITESSE_M1, 1); + gpio_put(PIN_SENS_A_M1, 1); + gpio_put(PIN_SENS_B_M1, 0); + + + +} + +int M1_RECULE() +{ + + gpio_put(PIN_VITESSE_M1, 1); + gpio_put(PIN_SENS_A_M1, 0); + gpio_put(PIN_SENS_B_M1, 1); + + + +} + + + + + + + +void main() +{ + stdio_init_all(); + + // CLignottement LED + gpio_set_function(LED_VERTE, GPIO_FUNC_PWM); + pwm_set_wrap(4, 100); + pwm_set_chan_level(4, PWM_CHAN_B, 25); + pwm_set_enabled(4, true); + + //Moteur 1 + + M1_INITIALISE(); + while(1) + { + + M1_AVANCE(); + sleep_ms(3000); + M1_RECULE(); + sleep_ms(3000); + + } + +} \ No newline at end of file