Raphael Schmidt
/
GrannyStepper
Projekt
Diff: main.cpp
- Revision:
- 34:f035a1869c34
- Parent:
- 33:cce9a88a307a
- Child:
- 35:57b39290aaea
--- a/main.cpp Wed Mar 30 10:34:39 2022 +0200 +++ b/main.cpp Wed Apr 06 09:32:30 2022 +0200 @@ -1,12 +1,19 @@ //GrannyStepper #include "mbed.h" #include "PM2_Libary.h" +#include <iostream> +using namespace std; //Eingänge -InterruptIn user_button(PC_13); //Blauer Taster für Startsignal +DigitalIn user_button(PC_13); + //Ausgänge DigitalOut enable_motors(PB_15); // Motoren freischalten +// while loop gets executed every main_task_period_ms milliseconds +int main_task_period_ms = 50; // define main task period time in ms e.g. 50 ms -> main task runns 20 times per second +Timer main_task_timer; // create Timer object which we use to run the main task every main task period time in ms + //DC-Motoren float pwm_period_s = 0.00005f; //PWM-Periode fürd DC-Motoren definiert FastPWM pwm_M1(PB_13); @@ -25,5 +32,34 @@ float max_speed_rps = 0.5f; // define maximum speed that the position controller is changig the speed, has to be smaller or equal to kn * max_voltage +int main(){ + enable_motors = 1; + user_button.read(); + + int counter_user_button, counter_stopp = 0; + if (user_button == 1 && counter_stopp == 0) { + counter_user_button++; + counter_stopp = 1; + + } + if (user_button == 0){ + counter_stopp = 0; + } + if (counter_user_button >= 3){ + counter_user_button = 1; + } + switch (counter_user_button){ + case 1: + cout <<"case1"; + break; + case 2: + cout <<"case2"; + break; + } + + + +} +