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.
Dependencies: MODSERIAL QEI mbed-dsp mbed
Fork of PI_controller_verbeteringen by
Revision 4:651d06e860e7, committed 2018-09-12
- Comitter:
- SimonRez
- Date:
- Wed Sep 12 12:18:25 2018 +0000
- Parent:
- 3:40a25c2c24ba
- Child:
- 5:f07bafaf11d7
- Commit message:
- SW2 checkt de kleur en geeft hem aan via serial; SW3 zet de led lamp uit en alle waarden van variabelen op NULL
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Sep 12 11:52:10 2018 +0000
+++ b/main.cpp Wed Sep 12 12:18:25 2018 +0000
@@ -6,14 +6,16 @@
DigitalOut ledr(LED_RED);
DigitalOut ledg(LED_GREEN);
DigitalOut ledb(LED_BLUE);
-DigitalIn sw2(PTC6);
+
+InterruptIn sw2(SW2);
+InterruptIn sw3(SW3);
MODSERIAL pc(USBTX, USBRX);
volatile char c;
volatile char color;
-void ButtonpressCheck()
+void Buttonpress()
{
if (c == 'r')
{
@@ -82,6 +84,7 @@
ledg = 1;
ledb = !ledb;
}
+
wait(0.25f);
ledr = 1;
ledg = 1;
@@ -89,24 +92,54 @@
}
+void CurrentColor()
+{
+ if (color == 'r')
+ {
+ pc.printf("The current blinking color is: red. \r\n");
+ }
+ else if (color == 'g')
+ {
+ pc.printf("The current blinking color is: green. \r\n");
+ }
+ else if (color == 'b')
+ {
+ pc.printf("The current blinking color is: blue. \r\n");
+ }
+ else
+ {
+ pc.printf("The LED is currently not blinking.\r\n");
+ }
+}
+
+void LEDOFF()
+{
+ color = NULL;
+ c = NULL;
+
+ ledr = 1;
+ ledg = 1;
+ ledb = 1;
+}
+
int main()
{
ledr = 1;
ledg = 1;
ledb = 1;
- pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~Pu$$Y~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n");
+ pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~A$$De$troyer69~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n");
pc.baud(115200);
- Blinker.attach(ButtonpressCheck, 0.5);
-
+ Blinker.attach(Buttonpress, 0.5);
+ sw2.fall(CurrentColor);
+ sw3.rise(LEDOFF);
while (true)
{
c = pc.getc();
-
}
}
