HEPTA-Sat Training 2020
/
Lab3-01_save_the_letters
for textbook v4.4
main.cpp@26:f15b873a018c, 2019-08-27 (annotated)
- Committer:
- HeptaSatTraining2019
- Date:
- Tue Aug 27 03:56:26 2019 +0000
- Revision:
- 26:f15b873a018c
- Parent:
- 25:5fd40a170032
- Child:
- 27:210fe762fa94
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
HeptaSatTraining2019 | 25:5fd40a170032 | 2 | #include "HEPTA_CDH.h" |
HeptaSatTraining2019 | 26:f15b873a018c | 3 | |
umeume | 2:1c5cdb2c3e0f | 4 | Serial pc(USBTX,USBRX); |
HeptaSatTraining2019 | 26:f15b873a018c | 5 | HEPTA_CDH cdh(p5, p6, p7, p8, "sd"); |
HeptaSatTraining2019 | 26:f15b873a018c | 6 | |
umeume | 2:1c5cdb2c3e0f | 7 | int main() |
umeume | 2:1c5cdb2c3e0f | 8 | { |
HeptaSatTraining2019 | 26:f15b873a018c | 9 | pc.baud(9600); |
HeptaSatTraining2019 | 26:f15b873a018c | 10 | pc.printf("Hello world!\r\n"); |
HeptaSatTraining2019 | 26:f15b873a018c | 11 | char str[100]; |
HeptaSatTraining2019 | 26:f15b873a018c | 12 | mkdir("/sd/mydir", 0777); |
HeptaSatTraining2019 | 26:f15b873a018c | 13 | FILE *fp = fopen("/sd/mydir/test.txt","w"); |
HeptaSatTraining2019 | 26:f15b873a018c | 14 | if(fp == NULL) { |
HeptaSatTraining2019 | 26:f15b873a018c | 15 | error("Could not open file for write\r\n"); |
HeptaSatTraining2019 | 26:f15b873a018c | 16 | } |
HeptaSatTraining2019 | 26:f15b873a018c | 17 | for(int i=0; i<10; i++)fprintf(fp,"Hello my name is HEPTA!\r\n"); |
HeptaSatTraining2019 | 26:f15b873a018c | 18 | fclose(fp); |
HeptaSatTraining2019 | 26:f15b873a018c | 19 | fp = fopen("/sd/mydir/test.txt","r"); |
HeptaSatTraining2019 | 26:f15b873a018c | 20 | for(int j = 0; j < 10; j++) { |
HeptaSatTraining2019 | 26:f15b873a018c | 21 | fgets(str,100,fp); |
HeptaSatTraining2019 | 26:f15b873a018c | 22 | puts(str); |
HeptaSatTraining2019 | 26:f15b873a018c | 23 | } |
HeptaSatTraining2019 | 26:f15b873a018c | 24 | fclose(fp); |
HeptaSatTraining2019 | 26:f15b873a018c | 25 | pc.printf("Goodbye!!\r\n"); |
umeume | 2:1c5cdb2c3e0f | 26 | } |