/* Robot Controls Generate PWM signals to control motors. By: Alexander Bobkov Date: Dec 21, 2024 built-in LED GPIO: 10 build-in push button GPIO: 3 */ #include #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/queue.h" #include "driver/gpio.h" #include "driver/ledc.h" #include "driver/mcpwm.h" #include "esp_log.h" #include "led_strip.h" #include "sdkconfig.h" static const char *TAG = "ESP IDF Robot"; // LED #define LEDC_TIMER LEDC_TIMER_0 #define LEDC_MODE LEDC_LOW_SPEED_MODE // LEDC_LOW_SPEED_MODE #define LEDC_OUTPUT_IO (5) // Define the output GPIO #define LEDC_CHANNEL LEDC_CHANNEL_0 #define LEDC_DUTY_RES LEDC_TIMER_10_BIT // Set duty resolution to 13 bits #define LEDC_DUTY (4096) // Set duty to 50%. (2 ** 13) * 50% = 4096 1024 #define LEDC_FREQUENCY (5000) // For LED the freuqncy of 500Hz seemed to be sufficient. // Frequency in Hertz. For DC motor, set frequency at 5 kHz /* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink, or you can edit the following line and set a number here. */ // Retrieve values from configuration menu #define BLINK_GPIO CONFIG_BLINK_GPIO // 10 GPIO of on-board LED #define PUSH_BTN_GPIO CONFIG_BUTTON_GPIO // 3 GPIO of on-board push-button #define MTR_FL_GPIO CONFIG_MOTOR_FRONT_LEFT_GPIO #define ESP_INTR_FLAG_DEFAULT 0 #define GPIO_INPUT_PIN_SEL ((1ULL<