1int ForwordSignal=A1;
2int BackwordSignal=A4;
3int LEDs=3;
4int ForwordMotor=4;
5int BackwordMotor=12;
6int code1;
7int cod2;
8int FM=0;
9int BM=0;
10int state=0;
11int testRelay=8;
12
13
14
15void setup() {
16
17 Serial.begin(9600);
18 pinMode(ForwordSignal,INPUT);
19 pinMode(BackwordSignal,INPUT);
20 pinMode(ForwordMotor,OUTPUT);
21 pinMode(BackwordMotor,OUTPUT);
22 pinMode(LEDs,OUTPUT);
23 pinMode(testRelay,OUTPUT);
24
25
26}
27
28void loop() {
29 FM=analogRead(ForwordSignal);
30 BM=analogRead(BackwordSignal);
31
32 Serial.println("B");
33 Serial.println("----");
34 Serial.println("F");
35
36 if(FM>200)
37 {
38 digitalWrite(ForwordMotor,HIGH);
39 digitalWrite(BackwordMotor,LOW);
40 digitalWrite(testRelay,LOW);
41
42 state=1;
43 Serial.print("FM is");
44 Serial.println(FM);
45
46 }else if(BM>200)
47 {
48 digitalWrite(BackwordMotor,HIGH);
49 digitalWrite(ForwordMotor,LOW);
50 ;
51
52 Serial.print("BM is");
53 Serial.println(BM);
54
55 state=2;
56 }else{digitalWrite(ForwordMotor,HIGH);
57 digitalWrite(BackwordMotor,HIGH);
58 digitalWrite(testRelay,HIGH);
59
60 };
61
62
63
64}
Munt_Att
3 years ago
Programming the 2.5ghz interference. thanks for the tips