-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinal_sensor.ino
47 lines (43 loc) · 1.12 KB
/
final_sensor.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
int a=6, b=7 ,c=10, d=11, x=5, y=9;
float m,n;
int ch=0;//ports
void setup() {
// put your setup code here, to run once:
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
// pinMode(x,OUTPUT);
//pinMode(y,OUTPUT);
Serial.begin(9600);
Serial.println(" Credence robotics presents");
Serial.println();
Serial.println(" TEAM $$");
}
void loop() {
// put your main code here, to run repeatedly:
// digitalWrite(m,LOW); //buzzer
m =analogRead(0);
n=analogRead(2);
//if (Serial.available()>0)
//{
//ch=Serial.read();
//Serial.println(ch);
//if(ch=='i')
if(n>150 & m<150)
{
digitalWrite(a,HIGH); digitalWrite(b,LOW); digitalWrite(c,LOW);digitalWrite(d,HIGH); //right
}
else if(m>150 & n<150)
{
digitalWrite(a,LOW); digitalWrite(b,HIGH); digitalWrite(c,HIGH);digitalWrite(d,LOW);//left
}
else if(m<150 & n<150)
{
digitalWrite(a,HIGH); digitalWrite(b,LOW); digitalWrite(c,HIGH);digitalWrite(d,LOW); //forward
}
else
{
digitalWrite(a,LOW); digitalWrite(b,LOW); digitalWrite(c,LOW);digitalWrite(d,LOW); //stop
}
}