Deze sketch moet bij het intikken van een letter m of M een getal (bv 123.4) kunnen ontvangen. Dat eerste lukt mij, maar het getal krPreformatted textijg ik niet voor elkaar. dit is de sketch:`#include <Arduino.h>
#include "messages.h"
#include <Streaming.h> /* Streaming | Arduiniana */
#include "String.h"
#define KEY_MOVE_LC 0x60
#define KEY_MOVE_UC 0x40
int incomingByte = 0; // for incoming serial data
int commkey = 0; // for incoming serial data
int x;
char str[1];
boolean recvByte = false;
// Buffer to store incoming commands from serial port
String inData;
String comdata = "";
void setup() {
Serial.begin(9600);
Serial.println("Serial conection started, waiting for a command...");
Serial.print(">");
}// end setup
void loop() {
while (Serial.available() > 0)
{
char recieved = Serial.read();
switch (recieved) {
case 'm':
case 'M':
Serial.println("Move to: ");
getServovalue();
break;
default:
Serial.println("Invalid command");
break;
}// end switch
if (recieved == KEY_MOVE_LC || recieved == KEY_MOVE_UC) {
Serial.println("Got move command");
} else
{
Serial.print(">");
}
}// while
}// end loop
void getServovalue() {
String readString;
#define isdigit(X) (((X) >= '0') && ((X) <= '9'))
Serial.print("Enter value: ");
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the String readString
Serial.println(readString);
delay(2); //slow looping to allow buffer to fill with next character
}// end while
}// end getServovalue()
`