Hardware Reference
In-Depth Information
Listing 1-3. The New Version of main.cpp
#include <Arduino.h>
int main(void)
{
init();
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
return 0;
}
Looking at the source, there are two interesting items to note. First, main.cpp now looks to see if a USB
connection is defined and attached. Second, the void loop() code runs, and then a serial event is checked for.
If the event is found, then the code runs it.
Updated Serial Object
Sending data from serial is now asynchronous. The serial object depends on a parent object called stream , so it is
included automatically with HardwareSerial.h in your main sketch.
Updated Stream Class
The Stream class has been updated. This is part of the serial object and provides the search, find, and parse value
functions that the HardwareSerial object uses.
Constructor
The constructor simply sets the timeout for the serial port to a default of 1000 ms.
Stream() {_timeout=1000;}
Member Functions
The member functions are shown in Table 1-1 .
 
Search WWH ::




Custom Search