We have submitted the source code of our prototype project.... Here we have shown only the communication and synchronization among control pannel, master ship and servent bots. The communication between control pannel and master ship has been shown by bluetooth communication and the synchronization among the servent bots are shown in RF module.
#include<SoftwareSerial.h> | |
#include<Servo.h> | |
SoftwareSerial BT(10,11); //(tx,rx); | |
Servo servoTrans; | |
int i=0,x=0; | |
String str; | |
voidsetup() { | |
BT.begin(9600); | |
pinMode(8,OUTPUT); | |
pinMode(5,OUTPUT); | |
servoTrans.attach(3); | |
servoTrans.write(0); | |
Serial.begin(9600); | |
} | |
voidloop() { | |
while(BT.available()) | |
{ | |
delay(10); | |
char c=BT.read(); | |
str += c; | |
} | |
if (str=="led on") | |
{ | |
digitalWrite(8,HIGH); | |
} | |
elseif(str=="led off") | |
{ | |
digitalWrite(8,LOW); | |
} | |
/*if(str=="180") | |
{ | |
servoTrans.write(180); | |
delay (4) ; | |
} | |
if(str=="0") | |
{ | |
servoTrans.write(0); | |
delay (4) ; | |
} | |
*/ | |
if(str.toInt()>0) | |
{ | |
x=str.toInt(); | |
servoTrans.write(x); | |
} | |
str=""; | |
if(digitalRead(8)==HIGH) | |
{ | |
delay(500); | |
digitalWrite(5, HIGH); | |
} | |
elseif(digitalRead(8)==LOW) | |
{ | |
delay(500); | |
digitalWrite(5, LOW); | |
} | |
if(servoTrans.read()<=45) | |
{ | |
/*Send data*/ | |
} | |
} |
#include<VirtualWire.h>//Load the library | |
int mapped; //Define the temp float variable | |
int sensor = 0; // sensor middle pin on analog pin 0 | |
char msg[6]; | |
int x, y; | |
voidsetup() | |
{ | |
Serial.begin(9600); | |
vw_set_tx_pin(9); // Sets pin D12 as the TX pin | |
vw_setup(2000); // Bits per sec | |
pinMode(6,INPUT); | |
pinMode(5,OUTPUT); | |
} | |
voidloop() | |
{ | |
/*if (digitalRead(6) == HIGH) | |
{ | |
delay(500); | |
digitalWrite(5,HIGH); | |
} | |
else if(digitalRead(6)==LOW) | |
{ | |
delay(500); | |
} | |
*/ | |
x=100; | |
y=200; | |
if (digitalRead(6) == HIGH) { | |
mapped = y; | |
Serial.println(mapped); | |
dtostrf(mapped, 6, 2, msg); //converts the float into a char | |
vw_send((uint8_t *)msg, strlen(msg)); //transmits the data | |
vw_wait_tx(); // Wait until the whole message is gone | |
delay(50); | |
} | |
elseif(digitalRead(6) == LOW){ | |
mapped = 300; | |
Serial.println(mapped); | |
dtostrf(mapped, 6, 2, msg); //converts the float into a char | |
vw_send((uint8_t *)msg, strlen(msg)); //transmits the data | |
vw_wait_tx(); // Wait until the whole message is gone | |
delay(50); | |
} | |
} |
#include<VirtualWire.h>//Load the library | |
int mapped; //Define the temp float variable | |
int sensor = 0; // sensor middle pin on analog pin 0 | |
char msg[6]; | |
int x, y; | |
voidsetup() | |
{ | |
Serial.begin(9600); | |
vw_set_tx_pin(9); // Sets pin D12 as the TX pin | |
vw_setup(2000); // Bits per sec | |
pinMode(6,INPUT); | |
pinMode(5,OUTPUT); | |
} | |
voidloop() | |
{ | |
/*if (digitalRead(6) == HIGH) | |
{ | |
delay(500); | |
digitalWrite(5,HIGH); | |
} | |
else if(digitalRead(6)==LOW) | |
{ | |
delay(500); | |
} | |
*/ | |
x=100; | |
y=200; | |
if (digitalRead(6) == HIGH) { | |
mapped = y; | |
Serial.println(mapped); | |
dtostrf(mapped, 6, 2, msg); //converts the float into a char | |
vw_send((uint8_t *)msg, strlen(msg)); //transmits the data | |
vw_wait_tx(); // Wait until the whole message is gone | |
delay(50); | |
} | |
elseif(digitalRead(6) == LOW){ | |
mapped = 300; | |
Serial.println(mapped); | |
dtostrf(mapped, 6, 2, msg); //converts the float into a char | |
vw_send((uint8_t *)msg, strlen(msg)); //transmits the data | |
vw_wait_tx(); // Wait until the whole message is gone | |
delay(50); | |
} | |
} |
SpaceApps is a NASA incubator innovation program.