Introduction: Wireless Camera Robot
Hello all
This robot can communicate with other robots
this robot is use full in many ways suppose your child is study in his room you can see him that he study or playing suppose that a building were fell and many people want help this robot can go where human can not go this robot can programable so you can programeable so you can also play with it if you have more ideas please get me the ideas at Vishal01mehra@gmail.com
Step 1: Collecting Material
1.4.2 inc lcd
2.Arduino uno
3.LCD module for display
4.900 Pin bread bord
5. Arduino esplora microcontroller game bord module joysic and slider
6.Robot arm gripper
7.Jumper wires
8.MIcro servo x 10
9.Robnt body
10.NRF24lL01+2.4ghz antenna wireless transmeter module
11.RIP motion sensor
12.Ultrasonic sensor
13.Wireless camera and recever
14.mini projector
log on to www.ebay.in
Step 2: Programing Arduino
1. #include
2. #include
3
4. //UART PROTOCOL/////////////////////// Wireless cam robot
5. #define UART_FLAG 0XFF
6. //Moto////////////////////////////////
7. //PROTO: FLAG DEV DIRECTION EMPTY FLAG
8. #define MOTO 0X00
9. #define FORWARD 0X01 //MOTO COMMAND
10. #define BACKWARD 0X02
11. #define TURNLEFT 0X03
12. #define TURNRIGHT 0X04
13. #define CARSTOP 0X00
14. //Servo///////////////////////////////
15. //PROTO: FLAG DEV SERVONUM POS FLAG
16. #define SERVO 0X01
17. //Moto Speed//////////////////////////
18. //PROTO: FLAG DEV MOTOSIDE SPEED FLAG
19. #define MOTOSPEED 0X02
20. //////////////////////////////////////
21. int n = 1;
22. int flagCount = 0;
23. int tempData = 0;
24. int UARTReveived = 0;
25. int rxData[5];
26. //-------------------define motor----------------------------------------------//
27. AF_DCMotor motorL(3,MOTOR12_8KHZ); //connect to M3
28. AF_DCMotor motorR(4,MOTOR12_8KHZ); //connect to M4
29. int motor_speed = 200; //[modifid]motor speed 150-200,---min:100;max:255
30. int motor_delay = 400; //[modifid]delay time in step
31.
32. //-------------------define servo----------------------------------------------//
33. Servo hand_t_servo; // create servo object to control a servo
34. Servo hand_d_servo; // create servo object to control a servo
35. int hand_t_pos = 90; //
36. int hand_d_pos = 90; //
37. int hand_delay = 1; //[modifid] speed of hand
38.
39. //------------------main program-----------------------------------------------//
40. void loop()
41. {
42. if(Serial.available())
43. {
44. tempData = Serial.read();
45. delay(3);
46. if(tempData == UART_FLAG && flagCount < 2)
47. {
48. rxData[0] = tempData;
49. flagCount++;
50. }
51. else
52. {
53. rxData[n] = tempData;
54. n++;
55. }
56. if(flagCount == 2)
57. {
58. rxData[4] == UART_FLAG;
59. UARTReveived = 1;
60. n = 1;
61. flagCount = 0;
62. tempData = 0;
63. Serial.flush();
64. }
65. }
66. if(UARTReveived == 1)
67. {
68. Serial.print("rxData:");
69. Serial.print(rxData[0]);
70. Serial.println(rxData[1]);
71. if(rxData[1] == MOTO)
72. {
73. switch(rxData[2])
74. {
75. case FORWARD:
76. carGoFwd();
77. break;
78. case BACKWARD:
79. carGoBwd();
80. break;
81. case TURNLEFT:
82. carTurnL();
83. break;
84. case TURNRIGHT:
85. carTurnR();
86. break;
87. case CARSTOP:
88. carStop();
89. break;
90. }
91. UARTReveived = 0;
92. }
93. else if(rxData[1] == SERVO)
94. {
95. servoSet(rxData[2], rxData[3]);
96. UARTReveived = 0;
97. }
98. else if(rxData[1] == MOTOSPEED)
99. {
100. CHNSpeed(rxData[2], rxData[3]);
Step 3: Programing Arduino
101. UARTReveived = 0;
102. } 103. } 104. } 105. 106. //CAR MOVEMENTS 107. void carGoFwd() 108. { 109. motorL.setSpeed(motor_speed); 110. motorR.setSpeed(motor_speed); 111. motorL.run(FORWARD); 112. motorR.run(FORWARD); 113. Serial.print("forward"); 114. delay(motor_delay); 115. } 116. void carGoBwd() 117. { 118. motorL.setSpeed(motor_speed); 119. motorR.setSpeed(motor_speed); 120. motorL.run(BACKWARD); 121. motorR.run(BACKWARD); 122. Serial.print("Backward"); 123. delay(motor_delay); 124. } 125. void carTurnL() 126. {
127. motorL.setSpeed(motor_speed); 128. motorR.setSpeed(motor_speed); 129. motorL.run(BACKWARD); 130. motorR.run(FORWARD); 131. delay(motor_delay); 132. Serial.print("TurnL"); 133. } 134. void carTurnR() 135. { 136. motorL.setSpeed(motor_speed); 137. motorR.setSpeed(motor_speed); 138. motorL.run(FORWARD); 139. motorR.run(BACKWARD); 140. delay(motor_delay); 141. Serial.print("TurnR"); 142. } 143. void carStop() 144. { 145. b_motor_stop(); 146. Serial.print("carStop"); 147. delay(5); 148. } 149. //CAR SPEED 150. void CHNSpeed(int wheelDIR, int wheelSpeed) 151. { 152. if(wheelDIR == 0X01) //LEFT WHEEL 153. { 154. motorL.setSpeed(wheelSpeed); 155. } 156. else if(wheelDIR == 0X02) //RIGHT WHEEL 157. { 158. motorR.setSpeed(wheelSpeed); 159. } 160. } 161. //SERVO TURN 162. void servoSet(int servoNum, int pos) 163. { 164. if(pos > 180) pos = 160; 165. else if(pos < 0) pos = 0; 166. switch(servoNum) 167. { 168. case 0X07: 169. hand_t_servo.write(pos); 170. Serial.print("X"); 171. Serial.print(pos); 172. break; 173. case 0X08: 174. hand_d_servo.write(pos); 175. Serial.print("Y"); 176. Serial.print(pos); 177. break; 178. } 179. } 180. void setup() 181. { 182. Serial.begin(9600); 183. b_motor_stop(); 184. b_servo_ini(); 185. //delay(2000); //waiting time 186. Serial.println("Hello! Wifi Car"); 187. } 188. 189. void b_motor_stop(){ 190. motorL.run(RELEASE); 191. motorR.run(RELEASE); 192. } 193. 194. void b_servo_ini(){ 195. hand_t_servo.attach(9); // attaches the servo on pin 9 to the servo object 196. hand_d_servo.attach(10); // attaches the servo on pin 10 to the servo object 197. hand_t_servo.write(hand_t_pos); 198. hand_d_servo.write(hand_d_pos); 199. }
Step 4: Programing Wireless Controller
(Transmeter)
/*
- WHAT IT DOES: Reads
Analog values on A0, A1 and transmits
them over a nRF24L01 Radio Link to another transceiver.
1 - GND
2 - VCC 3.3V !!! NOT 5V
3 - CE to Arduino pin 9
4 - CSN to Arduino pin 10
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11 Transmeter
7 - MISO to Arduino pin 12
8 - UNUSED
- Analog Joystick:
GND to Arduino GND
VCC to Arduino +5V
X Pot to Arduino A0
Y Pot to Arduino A1
*
*-----( Import needed libraries )-----*/
#include
#include
#include
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN 9
#define CSN_PIN 10
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int joystick[2]; // 2 element array holding Joystick readings
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
joystick[0] = analogRead(JOYSTICK_X);
joystick[1] = analogRead(JOYSTICK_Y);
radio.write( joystick, sizeof(joystick) );
}//--(end main loop )--
(Recever)
/*
- WHAT IT DOES: Receives data from another
transceiver with
2 Analog values from a Joystick
Displays received values on Serial Monitor
Recever
1 - GND
2 - VCC 3.3V !!! NOT 5V
3 - CE to Arduino pin 9
4 - CSN to Arduino pin 10
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11
7 - MISO to Arduino pin 12
8 - UNUSED
/*-----( Import needed libraries )-----*/
#include
#include
#include
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN 9
#define CSN_PIN 10
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int joystick[2]; // 2 element array holding Joystick readings
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();;
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
if ( radio.available() )
{ // Read the data payload until we've received everything
bool done = false;
while (!done)
{ // Fetch the data payload
done = radio.read( joystick, sizeof(joystick) );
Serial.print("X = ");
Serial.print(joystick[0]);
Serial.print(" Y = ");
Serial.println(joystick[1]);
}
}
else
{
Serial.println("No radio available");
}
}//--(end main loop )---