0% found this document useful (0 votes)
16 views2 pages

Codigo

Uploaded by

Francisco Garcia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Codigo

Uploaded by

Francisco Garcia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.-#include <Servo.

h>

2.-#include <SoftwareSerial.h>

3.-SoftwareSerial bluetooth(2, 3);// TX,RX

4.-

5.-Servo s1,s2,s3;

6.-

7.-String bt,bta,btb,btc;

8.-

9.-int d1,d2,d3;

10.-

11.-void setup()

12.-{

13.-s1.attach(5);

14.- s2.attach(6);

15.-s3.attach(7);

16.-Serial.begin(9600);

17.-bluetooth.begin(9600);

18.-}

19.-

20.-void loop()

21.-{

22.-if(bluetooth.available())

23.-{

24.- bt=bluetooth.readString();

25.- if(bt.indexOf("1#F") > -1)//servo 1

26.- {

27.-bta=bt.substring(3,bt.length());

28.- btb=bta.indexOf('>');

29.-btc=bta.substring(0,btb.toInt());
30.- Serial.println(btc);

31.-d1 = (btc.toInt());

32.-s1.write(d1);

33.-}

34.-if(bt.indexOf("2#F") > -1)//servo 2

35.-{

36.- bta=bt.substring(3,bt.length());

37.-7.-btb=bta.indexOf('>');

38.-btc=bta.substring(0,btb.toInt());

39.-Serial.println(btc);

40.-d2 = (btc.toInt());

41.-s2.write(d2);

42.-}

43.-if(bt.indexOf("3#F") > -1)//servo 3

44.-{

45.-bta=bt.substring(3,bt.length());

46.-btb=bta.indexOf('>');

47.-btc=bta.substring(0,btb.toInt());

48.-Serial.println(btc);

49.-d3 = (btc.toInt());

50.-s3.write(d3);

51.-}

52.-}

53.-}

You might also like