48 lines
998 B
C
48 lines
998 B
C
/*****
|
|
* Copyright (c) 2023 - Poivron Robotique
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
#include "pico/stdlib.h"
|
|
#include <stdio.h>
|
|
#define PIN_STEP 19
|
|
#define PIN_DIR 18
|
|
|
|
bool bouton_Presser = false;
|
|
void main(void)
|
|
{
|
|
stdio_init_all();
|
|
gpio_init(PIN_STEP);
|
|
gpio_init(PIN_DIR);
|
|
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=500;
|
|
while(1){
|
|
sleep_us(my_delay);
|
|
gpio_put(PIN_STEP, 1);
|
|
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, 0);
|
|
gpio_set_dir(PIN_STEP, GPIO_OUT);
|
|
}
|
|
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);
|
|
}
|
|
printf("%c %d\n", key,key);
|
|
}
|
|
|
|
|
|
}
|
|
}
|