// Stepper motor on Wokwi!
/*
Console Menu example for Arduino
Read data coming from console using the Serial.parseInt() function
and use for option select.
Created 13 Jun 2018
By Cenek Havelka
For www.utfg.info
*/
int receivedInt; //prepare variable for input
void setup() {
Serial.begin(9600); //setup console
//Print main menu
Serial.println("<MAIN MENU>");
Serial.println("------------------------");
Serial.println("1.)OPTION 1");
Serial.println("2.)OPTION 2");
Serial.println("3.)OPTION 3");
Serial.println("4.)OPTION 4");
Serial.println("------------------------");
}
void loop() {
recvInt(); //call function to read value from console
PrintByInput(); //call function with SWITCH
}
void recvInt() {
while(Serial.available() == 0) { } //wait for input from console
receivedInt = Serial.parseInt(); // parse input to INT, other values are ignored
}
void PrintByInput() {
if (receivedInt != NULL) { //call SWITCH if input is available
switch (receivedInt) { //print by input, otheway say !WRONG INPUT!
case 1:
Serial.print("OPTION-");
Serial.println(receivedInt);
break;
case 2:
Serial.print("OPTION-");
Serial.println(receivedInt);
break;
case 3:
Serial.print("OPTION-");
Serial.println(receivedInt);
break;
case 4:
Serial.print("OPTION-");
Serial.println(receivedInt);
break;
default:
Serial.println("!WRONG INPUT!");
break;
}
receivedInt = NULL;
}
}
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
stepper1:A-
stepper1:A+
stepper1:B+
stepper1:B-