Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 482 Bytes

README.md

File metadata and controls

24 lines (17 loc) · 482 Bytes

Serial communication with Arduino in C

Read a line from Arduino:

#include <termios.h>
#include "serial.h"

int main(int argc, char **argv) {
    int device = serial_open("dev/ttyACM0", B9600);
    char buffer[255];

    serial_read_until(device, buffer, '\n', 255);

    /* The buffer is guaranteed to have a terminating null
     * so it's safe to print right out
     */
    printf("Mesage from Arduino: %s\n", buffer);

    serial_close(device);

    return 0;
}