Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getInput(){
- int serAva; // i is a counter, serAva hold number of serial available
- char inByte;
- char inputBytes [4]={'\0','\0','\0','\0'}; // Array hold input bytes
- char * inputBytesPtr = &inputBytes[0]; // Pointer to the first element of the array
- while ((serAva=Serial.available()) <= 0) { //set serAva to how many bytes are available and wait until data arrives
- delay(50);
- }
- Serial.print("Bytes available: ");
- Serial.println(serAva);
- for(int i=0;i<serAva;i++){ //itterate through all the bytes present
- inputBytes[i]=Serial.read(); //Store the byte into array
- Serial.println(inputBytes[i]); //debug for varification
- }
- return atoi(inString); // Call atoi function and return result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement