-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAssembly
91 lines (43 loc) · 1.29 KB
/
Assembly
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
// defines pins numbers
/* all pins need to be mapped in the code the VVC and GND needs to be commented out.
This is so it is easy to find the correct value for VCC */
// Remote control arduino
// The ultrasound sensor
const int trigPin = 9;
const int echoPin = 10;
// VVC 5v
// defines variables
long duration;
int distance;
// The Line sensor
// The wheels
void setup() {
// Remote control
// The ultrasound sensor
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
// The Line sensor
// The wheels
}
void loop() {
// There is needet a start up sequence
// The ultrasound sensor
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
// The Line sensor
// The Left wheel
// The Right wheel
}