#include "mbed.h" #define MAX_LENGHT_LINE 6 #define MAX_LENGHT_FILE 100 DigitalOut LED_1(LED1); DigitalOut LED_2(LED2); DigitalOut LED_3(LED3); DigitalOut LED_4(LED4); // Create the local filesystem under the name "local" LocalFileSystem local("local"); char get_character; int i = 1; int j = 1; int hours = 0; int minutes = 0; int time_in_minutes = 0; int char_to_int[MAX_LENGHT_LINE]; int transmission_schedule[MAX_LENGHT_FILE] = {0}; int main() { FILE *userfile = NULL; userfile = fopen("userfile.txt", "r"); if (userfile != NULL) { do { for (i = 1; i <= 6; i++) { get_character = fgetc(userfile); char_to_int[i] = get_character - '0'; } hours = 10*char_to_int[1] + char_to_int[2]; minutes = 10*char_to_int[4] + char_to_int[5]; time_in_minutes = 60*hours + minutes; printf("The time wanted for transmission is %d:%d.\nThis corresponds to %d minute(s).\n",hours,minutes,time_in_minutes); transmission_schedule[j] = time_in_minutes/15; printf("This corresponds to %d second(s) in the mbed time scale\n\n",transmission_schedule[j]); j = j + 1; } while (get_character != EOF); fclose(userfile); } }