Hey! I am working on making a RC boat, powered by brushless motor and a servo.
So I am going to be using two button(for servo) and a potentiometer(for brushless motor 1000kv). on the transmitting end.
I will be using a brushless motor and servo on the receiving end.
PROBLEM 1:
So first trial I tried to control brushless motor, and servo separately. The servo part worked ,but when I am trying to transmit the potentiometer values, the values at the receiving end is disturbed. Here is the program.(NOTE: This program is only to check is the values transmitting and receiving are proper)
Transmitter
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10); //RX, TX
int vcc=8;
int gnd=9;
int pot=A0; //potentiometer pin
int potval;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(vcc,OUTPUT);
pinMode(gnd,OUTPUT);
pinMode(pot,INPUT);
}
void loop() {
digitalWrite(vcc,HIGH);
digitalWrite(gnd,LOW);
potval=analogRead(pot);
Serial.println(potval);
mySerial.println(potval);
delay(10);
}
Receiver
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10); //RX, TX
int vcc=8;
int gnd=9;
int input;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(vcc,OUTPUT);
pinMode(gnd,OUTPUT);
}
void loop() {
digitalWrite(vcc,HIGH);
digitalWrite(gnd,LOW);
input=mySerial.parseInt();
Serial.println(input);
delay(10);
}
and here is the output I get
223
2249
3
277
2292
2
318
3337
59
13370
407
25675
464
15744
515
-10007
5542
-9986
5559
5570
5580
5
596
6604
621
6635
642
6654
4
682
6693
8
715
7728
43
6656
7777
1366
814
23297
8851
23331
8883
8903
9911
9
929
9943
962
9963
969
9971
5
973
9974
36
975
9974
76
5110
7975
-3067
976
-31091
9993
-31095
9986
9987
9992
9
993
9994
991
9993
994
9953
1
988
9950
65
11669
942
-5265
798
23531
9955
-31185
8793
6659
5572
5522
5492
4
459
4438
402
3366
4
321
3300
1
265
2242
22
24024
141
12190
39
328
25
115
115
17
110
11
112
112
26
313
13
112
114
14
34
13
514
2266
962
1
19
716
1134
116
6
15
115
1113
113
35
14
115
1112
114
I don't understand what is the problem here and how to correct it.
Problem 2:
I want to control the brushless motor and the servo. So the signal transmitted should differentiate which is for servo and which is for brushless. I am not sure how this problem should be tackled and what should be done.
Thanks in advance.