用单片机最便宜,也最简单不过。写个小程序轻松搞定!
E. a3 O8 n$ N& O注KM-----电机控制
7 w, J7 v4 R q8 U SB-----按键(自己随便定义IO口), Q! H. k/ A% P
#include<reg51.h> + d6 R' V, ^( q
sbit KM=P0^0;. @5 ` y4 ?8 s; C
sbit SB=P1^4;
0 R/ h) K8 o5 T& P* A2 \ void mDelay(unsigned int Delay). {8 |! X5 D1 |- f8 k( c8 P# |* z, D
{ unsigned int i;
7 J$ ]% |1 Q W% L7 y for(;Delay>0;Delay--)
& {- K: p0 {8 R3 D, l7 U { for(i=0;i<124;i++)
: w2 N5 M2 X# Z3 i5 X) I F {;}) K# z$ x# g/ l+ y- [
} 1 {4 [4 \0 x$ m7 p5 \# ?
} 6 }/ u& b7 M; F7 M+ n4 ^& i2 U* X
void main()
" x' i1 T+ l# |( g4 I1 m {6 R* c( M! H+ c( c' {0 c4 V
while(1), u- m; \- n2 C' k/ e: T+ C, F
{
$ g% P m2 T3 F9 M if(SB==0)
# v; r0 u! u6 S" y+ V { , t7 K b u6 h
mDelay(100);# s4 Z' f9 l" s2 Y1 Z
KM=!KM;$ I. w. W1 b5 F: {: g' p
while(SB==0); //等待键释放
7 ]$ _1 M% S& R" L5 d" G4 G mDelay(100);: f7 B$ T3 u5 y" W: \
}
5 W7 {$ n5 N% h- ]' f A. R
0 K1 l% A! n% ~, _4 I } $ c: E7 l# n5 V0 L1 M" @$ a
}7 q' t" ^2 S: o/ o
至于PLC就更简单了,LD X0 ALT Y0 |