#include <Arduino.h>

void setup() {
RCC->AHBENR |= (1 << 2);
GPIOA->MODER &= ~(0xFF);
GPIOA->MODER |= 0x55;
Serial.begin(115200);
pinMode(A0, INPUT);
pinMode(A1, INPUT_PULLDOWN);

}
int taste = 0;
int richtung = 0;

void laufen(int i) {
    GPIOA->ODR = 0b1100;
    delay(i);
    GPIOA->ODR = 0b0110;
    delay(i);
    GPIOA->ODR = 0b0011;
    delay(i);
    GPIOA->ODR = 0b1001;
    delay(i);
}
 
void rück(int i) {
    GPIOA->ODR = 0b1001;
    delay(i);
    GPIOA->ODR = 0b0011;
    delay(i);
    GPIOA->ODR = 0b0110;
    delay(i);
    GPIOA->ODR = 0b1100;
    delay(i);
}

void loop() {
  int i = analogRead(A0);
  i = (i*100)/915;
  delay(10);
  taste = digitalRead(A1);
  Serial.println(taste);
  Serial.println(i);
  if(taste==0){
    Serial.println("vor");
    laufen(i);
  }else if(taste==1){
    Serial.println("rück");
    rück(i);
   }

}