Untitled


SUBMITTED BY: Guest

DATE: April 24, 2014, 7:28 p.m.

FORMAT: Text only

SIZE: 852 Bytes

HITS: 1123

  1. void loop() {
  2. if (Serial.available()) {
  3. digitalWrite(13, HIGH);
  4. }
  5. else {
  6. digitalWrite(13, LOW);
  7. }
  8. // put your main code here, to run repeatedly:
  9. while (Serial.available()) {
  10. delay(3); //delay to allow buffer to fill
  11. if (Serial.available() > 0) {
  12. char c = Serial.read(); //gets one byte from serial buffer
  13. readString += c; //makes the string readString
  14. }
  15. }
  16. // handle commands, if any detected
  17. // if not, repeat what was sent
  18. if (readString != "" && Serial.available() <= 0) {
  19. if (readString == "/hello") { // handle the '/hello'
  20. Serial.println("Hi there, Master!");
  21. }
  22. else { // repeat what was said
  23. Serial.println(readString);
  24. readString = "";
  25. }
  26. }
  27. }

comments powered by Disqus