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: mbed QEI MODSERIAL FastPWM ttmath Math
Revision 4:bd21569250c7, committed 2019-09-30
- Comitter:
- Feike
- Date:
- Mon Sep 30 11:36:51 2019 +0000
- Parent:
- 2:8f21971da95f
- Child:
- 5:fea5544804c1
- Child:
- 7:e119b12e5e7f
- Commit message:
- Robot-tryout
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor_tryout.cpp Mon Sep 30 11:36:51 2019 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+DigitalOut motor1_pwm(D3);
+MODSERIAL pc(USBTX, USBRX);
+int main(void)
+{
+ int frequency_pwm = 10000; //10 kHz PWM
+ PwmOut motor1_pwm(D3);
+ motor1_pwm.period(1.0/frequency_pwm); // T=1/f
+ while(true)
+ {
+ for(int pct = 0 ; pct <= 100 ; pct = pct +10)
+ {
+ motor1_pwm.write(pct/100.0); // write Duty Cycle
+ wait(0.1);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Ticker.cpp Mon Sep 30 11:36:51 2019 +0000
@@ -0,0 +1,36 @@
+// Initialize
+#include "mbed.h"
+#include "MODSERIAL.h"
+
+MODSERIAL pc(USBTX, USBRX);
+
+//volatile int 1 = DigitalOut myled(LED_GREEN);
+//volatile int 2 = DigitalOut myled(LED_BLUE);
+//volatile int 3 = DigitalOut myled(LED_RED);
+
+// Define Ticker
+Ticker BlinkLed;
+volatile char c;
+
+volatile int led1;
+volatile int led2;
+volatile int led3;
+
+void Lampje()
+{
+ if (c=='g') {
+ led1 = 1;}
+ if (c=='b') {
+ led2 = 1;}
+ if (c=='r') {
+ led3 = 1;}
+}
+
+int main() {
+ pc.baud(115200);
+ c = pc.getc();
+ BlinkLed.attach(Lampje,10);
+ pc.printf("Leuk dit!");
+ }
+
+