Vivien van Veldhuizen / Mbed 2 deprecated Signa-bot

Dependencies:   mbed QEI MODSERIAL FastPWM ttmath Math

Files at this revision

API Documentation at this revision

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

Motor_tryout.cpp Show annotated file Show diff for this revision Revisions of this file
Ticker.cpp Show annotated file Show diff for this revision Revisions of this file
main2.cpp Show annotated file Show diff for this revision Revisions of this file
--- /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!");
+    }
+
+