Example for Serial communication and LED Blinky
Fork of mbed-os-example-mbed5-blinky by
main.cpp
00001 /* SDT-example-blinky 00002 * 00003 * Copyright (c) 2018 Sigma Delta Technologies Inc. 00004 * 00005 * MIT License 00006 * 00007 * Permission is hereby granted, free of charge, to any person 00008 * obtaining a copy of this software and associated documentation 00009 * files (the "Software"), to deal in the Software without 00010 * restriction, including without limitation the rights to use, 00011 * copy, modify, merge, publish, distribute, sublicense, and/or sell 00012 * copies of the Software, and to permit persons to whom the 00013 * Software is furnished to do so, subject to the following 00014 * conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 00021 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00022 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 00023 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00024 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00025 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00026 * OTHER DEALINGS IN THE SOFTWARE. 00027 */ 00028 00029 #include "mbed.h" 00030 00031 /* Serial */ 00032 #define BAUDRATE 9600 00033 Serial g_Serial_pc(USBTX, USBRX, BAUDRATE); 00034 00035 /* DigitalOut */ 00036 #define LED_ON 0 00037 #define LED_OFF 1 00038 DigitalOut g_DO_LedRed(LED_RED, LED_OFF); 00039 DigitalOut g_DO_LedGreen(LED_GREEN, LED_OFF); 00040 DigitalOut g_DO_LedBlue(LED_BLUE, LED_OFF); 00041 00042 int main(void) { 00043 g_Serial_pc.printf("< Sigma Delta Technologies Inc. >\n\r"); 00044 00045 while(true) { 00046 g_Serial_pc.printf("LED Toggle\n"); 00047 g_DO_LedBlue = !g_DO_LedBlue; 00048 wait(1); // 1sec 00049 } 00050 00051 return 0; 00052 }
Generated on Tue Jul 12 2022 17:33:15 by 1.7.2