int ns=0; //decimal
int op=0; //0-conv 1-add 2
String inp1;
int inp2=0;
void setup() {
Serial.begin(9600);
Serial.println("hi");
}
void loop() {
// put your main code here, to run repeatedly:
modes();
}
void modes(){
if (ns==0){
Serial.println("dec");
if (op==0){
int inp=getinp();
Serial.println(inp);
String res=hextodec(inp);
Serial.println(res);
}
}
}
int getinp(){
Serial.println("Enter string:");
while (Serial.available() == 0) {
}
String inpstr = Serial.readString();
int inp = inpstr.toInt();
return inp;
}
String dectohex(int inp) {
char hex[4];
sprintf(hex, "%X", inp);
return String(hex);
}
String hextodec(String inp) {
char dec[4];
sprintf(dec, "%d", inp);
return String(dec);
}