2021_Colours_ModelRocket / Mbed 2 deprecated JY901_rawDate

Dependencies:   mbed SDFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  */
00005 
00006 #include "mbed.h"
00007 #include "SDFileSystem.h"
00008 //#include "platform/mbed_thread.h"
00009 
00010 Serial jy901(D1,D0);
00011 Serial pc(USBTX,USBRX);
00012 SDFileSystem sd(PA_7, PA_6, PA_5, PA_4, "sd"); // the pinout on the mbed Cool Components workshop board
00013 
00014 // Blinking rate in milliseconds
00015 int main()
00016 {
00017     jy901.baud(9600);
00018     printf("Hello World!\n"); 
00019  
00020     mkdir("/sd/mydir2", 0777);   
00021     FILE *fp = fopen("/sd/mydir2/sdtest.bin", "w");
00022     
00023     if(fp == NULL) {
00024         error("Could not open file for write\n");
00025     }
00026     
00027     while(1){    
00028         fputc(jy901.getc(),fp);
00029     }
00030     fclose(fp);   
00031 }