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.
include/EngineDriver.h
- Committer:
- overkiller
- Date:
- 2015-08-13
- Revision:
- 5:1afe17a20a5b
- Parent:
- 4:cc391b3f3e57
- Child:
- 6:9eb153e1d472
File content as of revision 5:1afe17a20a5b:
#ifndef DRIVER_H
#define DRIVER_H
#include "mbed.h"
#include "SerialPrompt.h"
DigitalOut en1(D2);
DigitalOut en2(D4);
DigitalOut in1(D3);
DigitalOut in2(D5);
DigitalOut in3(D6);
DigitalOut in4(D7);
int inState[4] = {0,0,0,0};
void applyStates()
{
in1 = inState[0];
in2 = inState[1];
in3 = inState[2];
in4 = inState[3];
}
void resetEngines()
{
for(int i = 0; i < 4; ++i)
{
inState[i] = 0;
}
applyStates();
}
void forward()
{
resetEngines();
inState[0] = 0;
inState[1] = 1;
inState[2] = 0;
inState[3] = 1;
applyStates();
}
void testEngines()
{
int i = 0;
while(i < 4)
{
if(i % 2 == 0)
{
inState[i] = 1;
}
i++;
}
applyStates();
wait(5);
resetEngines();
int j = 0;
while(j < 4)
{
if(j % 2 != 0)
{
inState[j] = 1;
}
j++;
}
applyStates();
wait(5);
resetEngines();
}
void enableAll()
{
en1 = 1;
en2 = 1;
}
void enableOne(int which)
{
if(which == 0)
{
en1 = 1;
}else if(which == 1)
{
en2 = 1;
}
}
void disableAll()
{
en1 = 0;
en2 = 0;
}
void disableOne(int which)
{
if(which == 0)
{
en1 = 0;
}else if(which == 1)
{
en2 = 0;
}
}
#endif //DRIVER_H