Werkend motorscript met led feedback

Dependencies:   Encoder MODSERIAL mbed

Committer:
Rvs94
Date:
Mon Sep 21 10:11:51 2015 +0000
Revision:
0:c8684fed9b61
Child:
1:4e65a72b622e
Motor werkt op dit script, alleen nog niet naar behoren. LED feedback toegevoegd.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rvs94 0:c8684fed9b61 1 #include "mbed.h"
Rvs94 0:c8684fed9b61 2 #include "encoder.h"
Rvs94 0:c8684fed9b61 3 #include "MODSERIAL.h"
Rvs94 0:c8684fed9b61 4
Rvs94 0:c8684fed9b61 5 Serial pc(USBTX, USBRX); // tx, rx
Rvs94 0:c8684fed9b61 6 DigitalOut led(LED_RED);
Rvs94 0:c8684fed9b61 7 DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
Rvs94 0:c8684fed9b61 8 PwmOut motor2speed(D5);
Rvs94 0:c8684fed9b61 9 DigitalIn button1(SW3);
Rvs94 0:c8684fed9b61 10
Rvs94 0:c8684fed9b61 11 int main()
Rvs94 0:c8684fed9b61 12 {
Rvs94 0:c8684fed9b61 13 motor2direction = 0;
Rvs94 0:c8684fed9b61 14 motor2speed = 0;
Rvs94 0:c8684fed9b61 15 pc.baud(9600);
Rvs94 0:c8684fed9b61 16 while(true)
Rvs94 0:c8684fed9b61 17 {
Rvs94 0:c8684fed9b61 18 if(button1 == 1)
Rvs94 0:c8684fed9b61 19 {
Rvs94 0:c8684fed9b61 20 motor2direction = 1;
Rvs94 0:c8684fed9b61 21 motor2speed = 0.5f;
Rvs94 0:c8684fed9b61 22 pc.printf("het werkt");
Rvs94 0:c8684fed9b61 23 wait(1)
Rvs94 0:c8684fed9b61 24 led = 0;
Rvs94 0:c8684fed9b61 25 wait(0.2f)
Rvs94 0:c8684fed9b61 26 }
Rvs94 0:c8684fed9b61 27 }
Rvs94 0:c8684fed9b61 28 }