Phil 12.20.12

8:00 – FP

  • Installing arduino drivers and generally setting up environment.Done
  • Working on understanding ASCII serial communications
  • Serial echo:
    const unsigned int BAUD_RATE = 9600;
    
    void setup(){
      Serial.begin(BAUD_RATE);
    }
    
    void loop(){
      int numChars = Serial.available();
      if(numChars > 0){
        Serial.print("numChars = [");
        Serial.print(numChars);
        Serial.print("] string = ");
        for(int i = 0; i < numChars; ++i){
          // Serial.read returns the first byte (int?) of incoming serial data
          // available (or -1 if no data is available) - int
          char inp = Serial.read();
          Serial.print(inp);
        }
        Serial.println();
        Serial.println("ready");
      }
    }
  • Turns out that I don’t have Visual Studio here. Talking from C++ will have to wait until this afternoon.
  • The arduino book references arduino-serial.c for example c code. The book’s code is here.