summaryrefslogtreecommitdiff
path: root/tools/servo_test.cpp
blob: 9c26c2568a0dc4b1ac39d0ee52c8214bc735b497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
#include <inttypes.h>
#include "pico/stdio.h"
#include "pwm.hpp"

PWM pwm;

int main() {
    stdio_init_all();
    // Initialize MOSFET
    gpio_init(MICRO_DEFAULT_SERVO_ENABLE);
    gpio_set_dir(MICRO_DEFAULT_SERVO_ENABLE, GPIO_OUT);
    gpio_put(MICRO_DEFAULT_SERVO_ENABLE, 1);
    pwm.init();
    uint8_t duty_cycle = 13;
    while (1) {
        getchar();
        if (duty_cycle == 2) {
            duty_cycle = 13;
        }
        pwm.set_duty_cycle(duty_cycle);
        printf("Currenty Duty Cycle: %" PRIu8 "\n", duty_cycle);
        duty_cycle--;
    }
}