407 code

Dependencies:   mbed SeeedShieldBot BluetoothSerial

main.cpp

Committer:
duongphong
Date:
23 months ago
Revision:
1:6fe4d6e4c602
Parent:
0:ac051b1bec3c

File content as of revision 1:6fe4d6e4c602:

/*Code for ENGR407 Moving arm*/

#include "mbed.h"
#include "time.h"
#define timedelay 500
PwmOut LampStep(D3);
DigitalOut LampDir(D5);
AnalogIn ldr1in(A3);
AnalogIn ldr2in(A4);
DigitalOut ldr1out(D1);
DigitalOut ldr2out(D0);
DigitalOut PrismStep(D6);
DigitalOut PrismDir(D8);
DigitalIn button(USER_BUTTON);
Timer t;
DigitalOut led1(LED1);
DigitalOut ms1(PC_1);
DigitalOut ms2(PC_2);
DigitalOut ms3(PC_3);
/*void LampArm()
{
LampStep.write(0.01);
wait(10);
LampStep.write(0);
wait(1000);
}*/
/* 
void PrismMotor()
{
            
}
*/
int main()
{
LampDir.write(1);
ms1.write(3);
ms2.write(3);
ms3.write(3);
int counter = 0;
int x = 0;
x = button.read();
if (x == 0){
    for (counter = 0; counter<=100; counter++)
        {
        LampStep.period_ms(100);
        LampStep.pulsewidth_ms(5);
        //counter+=1;
        }
    }
else if (x == 1)
    { 
    LampStep.period_ms(0);
    LampStep.pulsewidth_ms(0);
    }
}