Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TextLCD_HelloWorld by
Diff: main.cpp
- Revision:
- 5:6f2d3689b015
- Parent:
- 4:0e5cead61795
- Child:
- 6:5fcb9eb2a1f1
diff -r 0e5cead61795 -r 6f2d3689b015 main.cpp
--- a/main.cpp Wed Mar 30 03:54:09 2016 +0000
+++ b/main.cpp Wed Mar 30 04:16:58 2016 +0000
@@ -5,41 +5,35 @@
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2); // rs, e, d4-d7
Serial ftdi(USBTX, USBRX);
-DigitalIn button(p21);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
-int count=0; // button count
-struct tm t; // current time will be stored here
+int time1=0; // button count
int main() {
lcd.printf("Welcome!\n");
- ftdi.printf("Enter current date and time:\r\n");
- ftdi.printf("YYYY MM DD HH MM SS[enter]\r\n\r\n");
- ftdi.scanf("%d %d %d %d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec);
- ftdi.printf("%d %d %d %d %d %d", t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
- ftdi.printf("\n\r");
-// ftdi.printf("-------------------------- \r\n");
-
- t.tm_year = t.tm_year - 1900; // adjust for tm structure required values
- t.tm_mon = t.tm_mon - 1;
-
- set_time(mktime(&t)); // set the time
+ ftdi.printf("Enter LED on time:\r\n");
+ ftdi.scanf("%d\n\r", &time1);
+ ftdi.printf(":%d\n\r", time1);
while(1)
{
- time_t seconds = time(NULL);
-
- if(button.read()==0) // if the button is pressed
- {
- while(button.read()==0); // wait until release
- wait_ms(20); // button debounce
- count++; // count up
- ftdi.printf("Time: %s \rButton count: %d \r\n",ctime(&seconds),count); // send data to terminal
- ftdi.printf("-------------------------- \r\n");
- lcd.printf("Time: %s \rcount: %d \n\r",ctime(&seconds),count);
-// lcd.printf("-------------------------- \r\n");
- }
+ void cls();
+ lcd.printf("LED on: %d\n", time1);
+ led1=1;
+ led2=1;
+ led3=1;
+ led4=1;
+ wait(time1);
+ led1=0;
+ led2=0;
+ led3=0;
+ led4=0;
+ wait(time1);
}
}
