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:
- 6:5fcb9eb2a1f1
- Parent:
- 5:6f2d3689b015
diff -r 6f2d3689b015 -r 5fcb9eb2a1f1 main.cpp
--- a/main.cpp Wed Mar 30 04:16:58 2016 +0000
+++ b/main.cpp Thu Mar 31 05:15:45 2016 +0000
@@ -5,10 +5,13 @@
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2); // rs, e, d4-d7
Serial ftdi(USBTX, USBRX);
+/*
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
+*/
+BusOut myleds(LED1,LED2,LED3, LED4);
int time1=0; // button count
@@ -16,24 +19,53 @@
int main() {
lcd.printf("Welcome!\n");
- ftdi.printf("Enter LED on time:\r\n");
- ftdi.scanf("%d\n\r", &time1);
+ ftdi.printf("Enter LED on time: ");
+ ftdi.scanf("%d", &time1);
ftdi.printf(":%d\n\r", time1);
while(1)
{
- 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);
+ if(!ftdi.readable())
+ {
+ lcd.printf("LED on: %d\n", time1);
+
+ myleds=15;
+ /*
+ led1=1;
+ led2=1;
+ led3=1;
+ led4=1;
+ */
+ wait(time1);
+ myleds=10;
+ /*led1=0;
+ led2=0;
+ led3=0;
+ led4=0;
+ */
+ wait(time1);
}
+
+ else if(ftdi.readable())
+ {
+ int a;
+ ftdi.scanf("%d", &a);
+ time1=a;
+ ftdi.printf("New time: %d\n\r", time1);
+
+ lcd.cls();
+ /*
+ _rs=0;
+ _d = 0x01;
+ wait(0.000040f); // most instructions take 40us
+ _e = 0;
+ wait(0.000040f);
+ _e = 1;
+ */
+
+ lcd.printf("LED on (new): %d\n\n", time1);
+ }
+ }
+
}
