08.11.2017 Views

arduino_básico_Michael_McRoberts

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Capítulo 9 ■ Servomecanismos<br />

223<br />

}<br />

}<br />

while (numChar--) {<br />

// Preenche o buffer com a string<br />

buffer[index++] = Serial.read();<br />

}<br />

splitString(buffer); // Executa a função splitString<br />

void splitString(char* data) {<br />

Serial.print("Data entered: ");<br />

Serial.println(data);<br />

char* parameter;<br />

parameter = strtok (data, " ,"); // De string para tokens<br />

while (parameter != NULL) { // Se ainda não atingimos o fim da string...<br />

setServo(parameter); // ...execute a função setServo<br />

parameter = strtok (NULL, " ,");<br />

}<br />

// Limpa o texto e os buffers seriais<br />

for (int x=0; x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!