-
Notifications
You must be signed in to change notification settings - Fork 0
/
ultrasonic.ino
89 lines (60 loc) · 1.05 KB
/
ultrasonic.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
//ultrasonic part
int trigPin = 12;
int echoPin = 11;
long duration;
int distance;
float SetPoint=40 ;
float error;
float delta_t=0;
float now=micros();
float error_old=0;
float ErrorSum;
float time_old=0;
float D=0;
float I=0;
float kp=1,ki=0,kd=0.1;
//temparature part
#include <DHT.h>
int Sensor=2;
float temp;
#define DHTTYPE DHT22
DHT dht(2 , DHTTYPE);
float SetPoint1=40;
float error1;
float delta_t1=0;
float now1=micros();
float error_old1=0;
float ErrorSum1;
float time_old1=0;
float D1=0;
float I1=0;
float kp1=1,ki1=0,kd1=0.1;
//robot part
int lf=4;
int lb=5;
int rf=6;
int rb=7;
int el=9;
int er=10;
int mspeed;
int state;
float u;
float u1;
//servo part
#include<Servo.h>
Servo Masrur;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
dht.begin();
pinMode(lf, OUTPUT);
pinMode(lb, OUTPUT);
pinMode(rf, OUTPUT);
pinMode(rb, OUTPUT);
Masrur.attach(8);
Masrur.write(95);
Serial.begin(9600);
}
void loop(){
forward();
}