commande par la liaison série, haut et bas
This commit is contained in:
parent
609e4659a7
commit
3763484a13
18
main.c
18
main.c
@ -14,28 +14,28 @@ void main(void)
|
||||
stdio_init_all();
|
||||
gpio_init(PIN_STEP);
|
||||
gpio_init(PIN_DIR);
|
||||
gpio_set_dir(PIN_STEP, GPIO_OUT);
|
||||
gpio_set_dir(PIN_STEP, GPIO_IN);
|
||||
gpio_set_dir(PIN_DIR, GPIO_OUT);
|
||||
|
||||
sleep_ms(3000);
|
||||
printf("kartoffen\n");
|
||||
const uint32_t my_delay=1;
|
||||
const uint32_t my_delay=500;
|
||||
while(1){
|
||||
sleep_ms(my_delay);
|
||||
sleep_us(my_delay);
|
||||
gpio_put(PIN_STEP, 1);
|
||||
sleep_ms(my_delay);
|
||||
sleep_us(my_delay);
|
||||
gpio_put(PIN_STEP, 0);
|
||||
int key = getchar_timeout_us(0); // get any pending key press but don't wait
|
||||
if (key != PICO_ERROR_TIMEOUT) {
|
||||
if(key == 'u' || key == 'U'){
|
||||
gpio_put(PIN_DIR, 1);
|
||||
gpio_set_dir(PIN_STEP, GPIO_OUT);
|
||||
}
|
||||
if(key == 'd' || key == 'D'){
|
||||
gpio_put(PIN_DIR, 0);
|
||||
gpio_set_dir(PIN_STEP, GPIO_OUT);
|
||||
}
|
||||
if(key == 's' || key == 'D'){
|
||||
if(key == 'd' || key == 'D'){
|
||||
gpio_put(PIN_DIR, 1);
|
||||
gpio_set_dir(PIN_STEP, GPIO_OUT);
|
||||
}
|
||||
if(key == 's' || key == 'S'){
|
||||
gpio_put(PIN_DIR, 0);
|
||||
gpio_set_dir(PIN_STEP, GPIO_IN);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user