|
~: Robo vehicle program in VC++ :~
void CToycarDlg::OnFwd()
{
// TODO: Add your control notification handler code here
_outp(0x0378,0x01);
Sleep(200);
_outp(0x0378,0x00)
t=0;
// MessageBox("motor is moving forward");
}
void CToycarDlg::OnRev()
{
// TODO: Add your control notification handler code here
_outp(0x0378,0x04);
Sleep(200);
_outp(0x0378,0x00);
t=1;
MessageBox("motor is moving Reverse");
}
void CToycarDlg::OnLeft()
{
// TODO: Add your control notification handler code here
if(t==0)
{
_outp(0x0378,0x03);
Sleep(200);
_outp(0x0378,0x00);
//MessageBox("motor is moving forward and taiking left turn");
}
else
{
//_outp(0x0378,0x06);
//Sleep(200);
//_outp(0x0378,0x00);
MessageBox("motor is moving reverse and taiking left turn");
}
}
void CToycarDlg::OnRight()
{
// TODO: Add your control notification handler code here
if(t==0)
{
_outp(0x0378,0x09);
Sleep(200);
_outp(0x0378,0x00);
//MessageBox("motor is moving forward and taking right turn");
}
else
{
//_outp(0x0378,0x0C);
//Sleep(200);
//_outp(0x0378,0x00);
MessageBox("motor is moving reverse and taking right turn");
}
}
void CToycarDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if((nFlags & MK_LBUTTON) == MK_LBUTTON)
{
if(t==0)
{
_outp(0x0378,0x03);
//MessageBox("motor is moving forward and taking left turn");
}
else
{
//_outp(0x0378,0x06);
//MessageBox("motor is moving reverse and taking left turn");
}
}
else if((nFlags & MK_RBUTTON) == MK_RBUTTON)
{
if(t==0)
{
//_outp(0x0378,0x09);
//MessageBox("motor is moving forward and taiking right turn");
}
else
{
//_outp(0x0378,0x0C);
//MessageBox("motor is moving reverse and taiking right turn");
}
}
CDialog::OnMouseMove(nFlags, point);
}
void CToycarDlg::OnGo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//MessageBox("motor is start");
_outp(0x0378,0x01);
Sleep(m_id*500);
_outp(0x0378,0x00);
//MessageBox("motor is stoped");
} |