Please complete the participation activities under the E15 review section of the class zyBooks.
In this lecture you will:
By the end of this lecture you should be able to:
<aside> 💡 For some of you, today’s content will be review. For others, it might include new information. I’ll try to thread the needle, but please ask questions if something doesn’t make sense to you.
</aside>
For more information on C++, see C++ Resources.
To follow along, duplicate your lab 0 program (right click on it in Mbed studio and choose “duplicate”). If you haven’t set up your Github yet, you can also download and extract the .zip file from here.
The code examples we do in class will be shared here after class. Feel free to remind me if I don’t post them within 24 hours. I generally will not post the answers to the in class exercises, as these are essentially warm ups for the lab questions. But if you’re stuck on them, I am happy to work through a solution with you.
/*
* Copyright (c) 2006-2020 Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
#include "mbed.h"
static BufferedSerial pc(USBTX, USBRX);
int main()
{
char msg[] = "Echoes back to the screen anything you type\\n";
char buff;
pc.write(msg, sizeof(msg));
while (1) {
pc.read(&buff, 1);
pc.write(&buff, 1);
}
}
The characters we receive are what is called ASCII characters. They are a type that is a single byte called a char
.