Echos ASCII message converted to uppercase. Uses toupper function from standard C library.

Dependencies:   mbed

main.cpp

Committer:
CSTritt
Date:
2019-02-11
Revision:
4:0ed7a3594910
Parent:
3:041d6aaa4a7b

File content as of revision 4:0ed7a3594910:

/* 
    Project: SerialEcho
    File: main.cpp
    Created by: Dr. C. S. Tritt
    Last revised: 1/17/19 (v. 1.0)
    
    Receives serial data from PC to and echos it back, character for character.
    
    Tera Term configurations
    Terminal - New-line, Receive LF, Transmit LF
    Serial port - Data 8 bit, Parity none, Stop 1 bit, Flow control none.
    Baud as specified below.
*/
#include <cctype>
#include "mbed.h"

Serial pc(USBTX, USBRX, 9600); // Standard to PC via USB channel.

DigitalOut actLED(LED1); // Activity LED.

int main()
{
    while (true) {
        if (pc.readable()) {
            char myChar = (char) pc.getc(); // Get a char from the PC.            
            myChar = std::toupper(myChar);
            pc.putc(myChar); // Send it back to the PC.
            actLED = !actLED; // Toggle the activity LED.
        }
    }
}