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 2:52b3c0b95388, committed 2018-09-12
- Comitter:
- SimonRez
- Date:
- Wed Sep 12 10:27:38 2018 +0000
- Parent:
- 1:40470bc517f1
- Child:
- 3:40a25c2c24ba
- Commit message:
- Kleuren veranderen en juiste interval. Melding als verkeerd karakter is ingevoerd;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Sep 11 10:42:39 2017 +0000
+++ b/main.cpp Wed Sep 12 10:27:38 2018 +0000
@@ -1,19 +1,81 @@
#include "mbed.h"
#include "MODSERIAL.h"
-DigitalOut myled(LED_GREEN);
+Ticker Blinker;
+
+DigitalOut ledr(LED_RED);
+DigitalOut ledg(LED_GREEN);
+DigitalOut ledb(LED_BLUE);
+DigitalIn sw2(PTC6);
+
MODSERIAL pc(USBTX, USBRX);
+volatile char c;
+volatile char color;
+
+void ButtonpressCheck()
+{
+ if (c == 'r')
+ {
+ color = 'r';
+ }
+ else if (c == 'g')
+ {
+ color = 'g';
+ }
+ else if (c == 'b')
+ {
+ color = 'b';
+ }
+ else
+ {
+ pc.printf("Character %c is not valid \r\n",c);
+ c = color;
+ }
+
+ if (color == 'r')
+ {
+ ledr = !ledr;
+ ledg = 1;
+ ledb = 1;
+ }
+ else if (color == 'g')
+ {
+ ledr = 1;
+ ledg = !ledg;
+ ledb = 1;
+ }
+ else if (color == 'b')
+ {
+ ledr = 1;
+ ledg = 1;
+ ledb = !ledb;
+ }
+ wait(0.25f);
+ ledr = 1;
+ ledg = 1;
+ ledb = 1;
+
+}
+
int main()
{
- int i = 0;
+ 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.baud(115200);
- pc.printf("Hello World!\r\n");
+ Blinker.attach(ButtonpressCheck, 0.5);
+
- while (true) {
- wait(0.5f); // wait a small period of time
- pc.printf("%d \r\n", i); // print the value of variable i
- i++; // increment the variable
- myled = !myled; // toggle a led
+
+ while (true)
+ {
+ c = pc.getc();
}
+
}
+
+
