農作物回収機構プログラム

Dependencies:   mbed arrc_mbed Motor

main.cpp

Committer:
m2130
Date:
2022-02-02
Revision:
0:417f3396cf67
Child:
1:7937f28c742d

File content as of revision 0:417f3396cf67:

//-----Libraries-----
#include "mbed.h"
#include "scrp_slave.hpp"
#include "motor.hpp"

//-----Classes-----
ScrpSlave slave(PC_12, PD_2, PH_1, SERIAL_TX, SERIAL_RX, 4);   //id: 4
Motor motor(PB_14, PB_13);

//-----Constants-----
const double pwm = 0.1;

//-----Sub Routines-----
bool Up(int RX,int &TX);
bool Down(int RX,int &TX);

//-----Variables-----
int up = 0;
int down = 0;

//-----Main Routine-----
int main(){
    slave.addCMD(1, Up);
    slave.addCMD(2, Down);
    while(1){
        motor.out(pwm * (up + down)); 
    }
}

bool Up(int RX, int &TX){
    up = RX;
    return true;
}

bool Down(int RX, int &TX){
    down = -RX;
    return true;
}