-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.ino
124 lines (87 loc) · 2.61 KB
/
new.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// int vSpeed = 3; // MAX 255
// int turn_speed = 3; // MAX 255
// int turn_delay = 5;
// //L293 Connection
// const int motorA1 = 8;
// const int motorA2 = 10;
// const int motorAspeed = 9;
// const int motorB1 = 12;
// const int motorB2 = 13;
// const int motorBspeed = 11;
// //Sensor Connection
// const int left_sensor_pin =A0;
// const int right_sensor_pin =A1;
// int left_sensor_state;
// int right_sensor_state;
// void setup() {
// pinMode(motorA1, OUTPUT);
// pinMode(motorA2, OUTPUT);
// pinMode(motorB1, OUTPUT);
// pinMode(motorB2, OUTPUT);
// Serial.begin(9600);
// delay(3000);
// }
// void loop() {
// left_sensor_state = analogRead(left_sensor_pin);
// right_sensor_state = analogRead(right_sensor_pin);
// if(right_sensor_state > 500 && left_sensor_state < 500)
// {
// Serial.println("turning right");
// digitalWrite (motorA1,LOW);
// digitalWrite(motorA2,HIGH);
// digitalWrite (motorB1,LOW);
// digitalWrite(motorB2,HIGH);
// analogWrite (motorAspeed, vSpeed);
// analogWrite (motorBspeed, turn_speed);
// }
// if(right_sensor_state < 500 && left_sensor_state > 500)
// {
// Serial.println("turning left");
// digitalWrite (motorA1,HIGH);
// digitalWrite(motorA2,LOW);
// digitalWrite (motorB1,HIGH);
// digitalWrite(motorB2,LOW);
// analogWrite (motorAspeed, turn_speed);
// analogWrite (motorBspeed, vSpeed);
// delay(turn_delay);
// }
// if(right_sensor_state > 500 && left_sensor_state > 500)
// {
// Serial.println("going forward");
// digitalWrite (motorA2,LOW);
// digitalWrite(motorA1,HIGH);
// digitalWrite (motorB2,HIGH);
// digitalWrite(motorB1,LOW);
// analogWrite (motorAspeed, vSpeed);
// analogWrite (motorBspeed, vSpeed);
// delay(turn_delay);
// }
// if(right_sensor_state < 500 && left_sensor_state < 500)
// {
// Serial.println("stop");
// analogWrite (motorAspeed, 0);
// analogWrite (motorBspeed, 0);
// }
// }
#define ENB 6
#define IN3 9
#define IN4 11
void setup(){
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
digitalWrite(ENB, HIGH);
}
void loop(){
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(500);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(500);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
delay(500);
digitalWrite(IN3, LOW);
digitalWrite(IN4,LOW);
}