-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBluetooth_Car.ino
58 lines (51 loc) · 1.47 KB
/
Bluetooth_Car.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
#include<avr/io.h>
char val; //This character is coming from phone to the bluetotth module and then goes from bluetooth module to arduino uno
void setup() {
Serial.begin(9600);
DDRB |= (1 << 0); //MA CW --->PIN 8
DDRB |= (1 << 1); //MA ACW --->PIN 9
DDRB |= (1 << 2); //MB CW --->PIN 10
DDRB |= (1 << 3); //MB ACW --->PIN 11
}
void loop() {
while (Serial.available() > 0)
{
val = Serial.read();
Serial.println(val);
}
if ( val == 'F') // Forward
{
PORTB |= (1 << 0); //MA CW --->PIN 8
PORTB &= ~(1 << 1); //MA ACW --->PIN 9
PORTB |= (1 << 2); //MB CW --->PIN 10
PORTB &= ~(1 << 3); //MB ACW --->PIN 11
}
else if (val == 'B') // Backward
{
PORTB &= ~ (1 << 0);//MA CW --->PIN 8
PORTB |= (1 << 1); //MA ACW --->PIN 9
PORTB &= ~(1 << 2); //MB CW --->PIN 10
PORTB |= (1 << 3); //MB ACW --->PIN 11
}
else if (val == 'L') //Left
{
PORTB |= (1 << 0); //MA CW --->PIN 8
PORTB &= ~(1 << 1); //MA ACW --->PIN 9
PORTB &= ~(1 << 2); //MB CW --->PIN 10
PORTB &= ~(1 << 3); //MB ACW --->PIN 11
}
else if (val == 'R') //Right
{
PORTB &= ~(1 << 0); //MA CW --->PIN 8
PORTB &= ~(1 << 1); //MA ACW --->PIN 9
PORTB |= (1 << 2); //MB CW --->PIN 10
PORTB &= ~(1 << 3); //MB ACW --->PIN 11
}
else if (val == 'S') //Stop
{
PORTB &= ~(1 << 0); //MA CW --->PIN 8
PORTB &= ~(1 << 1); //MA ACW --->PIN 9
PORTB &= ~(1 << 2); //MB CW --->PIN 10
PORTB &= ~(1 << 3); //MB ACW --->PIN 11
}
}