-
Notifications
You must be signed in to change notification settings - Fork 1
/
a_setup.ino
95 lines (72 loc) · 2.21 KB
/
a_setup.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
void setup(){
Serial.begin(9600);
// motor pins
pinMode(pwm_left,OUTPUT);
pinMode(cw_left,OUTPUT); //MOTOR1
pinMode(ccw_left,OUTPUT);
pinMode(pwm_right,OUTPUT);
pinMode(cw_right,OUTPUT); //MOTOR2
pinMode(ccw_right,OUTPUT);
pinMode(encoderPinA1,INPUT);
pinMode(encoderPinB1,INPUT);
pinMode(encoderPinA2,INPUT);
pinMode(encoderPinB2,INPUT);
attachInterrupt(digitalPinToInterrupt(encoderPinA1), readEncoder1, CHANGE);
attachInterrupt(digitalPinToInterrupt(encoderPinA2), readEncoder2, CHANGE);
//-----------------------------------------------------------------------
//ultrasonic --> not needed
//--------------------------------------------------------------------
// //bottom color sensor pins
// pinMode(S0_B, OUTPUT);
// pinMode(S1_B, OUTPUT);
// pinMode(S2_B, OUTPUT);
// pinMode(S3_B, OUTPUT);
//
// // Setting the sensorOut as an input
// pinMode(color_base_output, INPUT);
// // Setting frequency scaling to 20%
// digitalWrite(S0_B,HIGH);
// digitalWrite(S1_B,LOW);
//---------------------------------------------------
// //compass
// Wire.begin();
//
// /* Initialise the module */
// Init_HMC5883L();
//----------------------------------------
// //bottom color sensor pins
pinMode(S0_B, OUTPUT);
pinMode(S1_B, OUTPUT);
pinMode(S2_B, OUTPUT);
pinMode(S3_B, OUTPUT);
// Setting the sensorOut as an input
pinMode(color_base_output, INPUT);
// Setting frequency scaling to 20%
digitalWrite(S0_B,LOW); // low -- 20%
digitalWrite(S1_B,HIGH);
pinMode(S0_T, OUTPUT);
pinMode(S1_T, OUTPUT);
pinMode(S2_T, OUTPUT);
pinMode(S3_T, OUTPUT);
// Setting the sensorOut as an input
pinMode(color_top_output, INPUT);
// Setting frequency scaling to 20%
digitalWrite(S0_T,LOW);
digitalWrite(S1_T,HIGH);
//---------------------------------------------------
//compass
// Wire.begin();
/* Initialise the module */
// Init_HMC5883L();
//Stepper
pinMode (stp,OUTPUT);
pinMode (dir,OUTPUT);
pinMode (ms0,OUTPUT);
pinMode (ms1,OUTPUT);
pinMode (ms2, OUTPUT);
digitalWrite(stp,LOW);
digitalWrite(ms0,HIGH);
digitalWrite(ms1,HIGH);
digitalWrite(ms2,LOW);
myServo.attach(39);
}