Code_RX.c


1
#include <Servo.h>
2
#include <SoftwareSerial.h>
3
4
int command = 0;  //incoming serial data
5
Servo myservo;
6
SoftwareSerial bluetooth(A2, A3);
7
int val;
8
Servo head;
9
10
void setup() {
11
  bluetooth.begin(9600);
12
  Serial.begin(9600); // set up Serial library at 9600 bps - this is the speed the serial interface will work all
13
  myservo.attach(3);
14
15
16
17
}
18
19
void loop() {
20
 
21
  if (bluetooth.available()) {
22
    val = bluetooth.read();
23
    Serial.write(val);
24
    if (val >= '0' && val <= '180'){
25
    myservo.write(val);
26
    // Serial.write(cmd);
27
    }
28
  }
29
 }