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: FastPWM HIDScope MODSERIAL mbed
main.cpp
- Committer:
 - Mirjam
 - Date:
 - 2018-09-25
 - Revision:
 - 2:840f7aa50e55
 - Parent:
 - 1:d6acc3c6261a
 - Child:
 - 3:7421e53bf9bd
 
File content as of revision 2:840f7aa50e55:
#include "mbed.h"
#include "FastPWM.h"
#include "MODSERIAL.h"
#include "HIDScope.h"
AnalogIn  potmeter1(PTC10);
AnalogIn  potmeter2(PTC11);
MODSERIAL  pc(USBTX, USBRX);
//D4 is a digital input for the microcontroller, so should be an digitalOut
//from the K64F. It will tell the motor shiel to let Motor1 turn clockwise
//of count clockwise (CW of CCW). D4 for motor 2
DigitalOut directionM1(D4);
DigitalOut directionM2(D7);
//D5 is a PWM input for the motor controller and determines the PWM signal 
//that the motor controller gives to Motor 1. Higher PWM, higer average voltage.
// D6 for motor 2
FastPWM motor1_pwm(D5);
FastPWM motor2_pwm(D6);
// Voor het laten zien van de data op de pc.
HIDScope scope(2);              // Aantal kanalen wat doorgegeven wordt aan de hidscope
Ticker AInTicker;
float potwaarde1;
float potwaarde2;
void ReadAnalogIn()
{
    scope.set(0,potwaarde1);    // Zet de potwaarde in de eerste plot bij de HID scope. Deze wordt automatisch tegen de tijd geplot
    scope.set(1,potwaarde2);
    scope.send();               // Zendt de waardes naar de pc 
    }
int main(void)
{
    motor1_pwm.period_ms(60); // period is 60 ms
    AInTicker.attach(&ReadAnalogIn,0.01f);  //Elke 0.01 sec. Lees de analoge waarde
 
    while(true){
        potwaarde1 = potmeter1.read();  // Lees de potwaardes uit
        potwaarde2 = potmeter2.read();
               
        }
    
}