premierprog.c 702 Bytes

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(void)
{

char car;
char a;

int ard = open("/dev/ttyACM0",O_RDWR);

    while(1) 
        {
        read(ard, &car, 1);
        printf ("%c",car);

        switch(car) {

            case 'A':
            a = '1';
            break;
            case 'B':
            a = '6';
            break;
            case 'C':
            a = '3';
            break;
            case 'D':
            a = '4';
            break;
            case 'E':
            a = '5';
            break; }

        write(ard,&a,1); 
        }
    close(ard);
}