#![no_std]
#![no_main]

use arduino_hal::prelude::*;
use arduino_hal::delay::Delay;
use arduino_hal::port::mode::Output;
use arduino_hal::port::portd::{PD2, PD3, PD4, PD5};
use panic_halt as _;

#[arduino_hal::entry]
fn main() -> ! {
    let dp = arduino_hal::Peripherals::take().unwrap();
    let mut delay = Delay::new();

    // Configurar los pines utilizados para controlar el motor
    let mut dir_pin = PD2.into_output();
    let mut step_pin = PD3.into_output();
    let mut enable_pin = PD4.into_output();
    let mut reset_pin = PD5.into_output();

    // Inicializar los pines
    dir_pin.set_low();
    enable_pin.set_high();
    reset_pin.set_high();

    // Hacer que el motor gire hacia la izquierda durante 10 segundos
    for _ in 0..500 {
        step_pin.toggle();
        delay.delay_us(1000); // Retraso de 1 ms entre cada paso
    }

    // Invertir la dirección del motor
    dir_pin.set_high();

    // Hacer que el motor gire hacia la derecha durante 10 segundos
    for _ in 0..500 {
        step_pin.toggle();
        delay.delay_us(1000); // Retraso de 1 ms entre cada paso
    }

    loop {}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
A4988
drv1:ENABLE
drv1:MS1
drv1:MS2
drv1:MS3
drv1:RESET
drv1:SLEEP
drv1:STEP
drv1:DIR
drv1:GND.1
drv1:VDD
drv1:1B
drv1:1A
drv1:2A
drv1:2B
drv1:GND.2
drv1:VMOT
stepper2:A-
stepper2:A+
stepper2:B+
stepper2:B-