-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud_blynk_car.ino
103 lines (85 loc) · 1.65 KB
/
cloud_blynk_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
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
/*
* Akshayan Sinha
* Complete Project Details https://www.hackster.io/akshayansinha
*/
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
BlynkTimer timer;
int LeftA= ; //IN1
int LeftB= ; //IN2
int RightA= ; //IN3
int RightB= ; //IN4
char auth[] = " "; // You should get Auth Token in the Blynk App.
char ssid[] = " "; // Your Wi-Fi Credentials
char pass[] = " ";
void setup() {
pinMode(LeftA,OUTPUT);
pinMode(LeftB,OUTPUT);
pinMode(RightA,OUTPUT);
pinMode(RightB,OUTPUT);
pinMode(2, OUTPUT);
Serial.begin(9600);
Serial.println("WiFi connected");
Blynk.begin(auth, ssid, pass);
digitalWrite(2,HIGH);
}
BLYNK_WRITE(V0)
{
forward();
Serial.println("Forward");
}
BLYNK_WRITE(V1)
{
backward();
Serial.println("Backward");
}
BLYNK_WRITE(V2)
{
halt();
Serial.println("Stop");
}
BLYNK_WRITE(V3)
{
right();
Serial.println("Right");
}
BLYNK_WRITE(V4)
{
left();
Serial.println("Left");
}
void loop(){
Blynk.run();
}
void left() {
digitalWrite(LeftA,LOW);
digitalWrite(LeftB,HIGH);
digitalWrite(RightA,HIGH);
digitalWrite(RightB,LOW);
}
void right() {
digitalWrite(LeftA,HIGH);
digitalWrite(LeftB,LOW);
digitalWrite(RightA,LOW);
digitalWrite(RightB,HIGH);
}
void forward() {
digitalWrite(LeftA,HIGH);
digitalWrite(LeftB,LOW);
digitalWrite(RightA,HIGH);
digitalWrite(RightB,LOW);
}
void backward() {
digitalWrite(LeftA,LOW);
digitalWrite(LeftB,HIGH);
digitalWrite(RightA,LOW);
digitalWrite(RightB,HIGH);
}
void halt() {
digitalWrite(LeftA,LOW);
digitalWrite(LeftB,LOW);
digitalWrite(RightA,LOW);
digitalWrite(RightB,LOW);
}