Skip to content

Commit 61e117f

Browse files
author
Andre Courchesne
committed
- First commit
0 parents  commit 61e117f

File tree

21 files changed

+18334
-0
lines changed

21 files changed

+18334
-0
lines changed

Arduino/CreeperBot/CreeperBot.ino

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
// Includes
2+
#include <WiServer.h>
3+
#include <string.h>
4+
#include <Servo.h>
5+
6+
// Wireless configuration parameters
7+
unsigned char local_ip[] = { 192,168,0,10 }; // IP address of WiShield
8+
unsigned char gateway_ip[] = { 192.168,0,1 }; // router or gateway IP address
9+
unsigned char subnet_mask[] = { 255,255,255,0 }; // subnet mask for the local network
10+
char ssid[] = {"Robot"}; // max 32 bytes
11+
unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
12+
13+
// WPA/WPA2 passphrase (UNUSED)
14+
const char PROGMEM security_passphrase[] = { "12345678"}; // max 64 characters
15+
16+
// WEP 128-bit keys (UNUSED)
17+
//const unsigned char PROGMEM wep_keys[] = {
18+
// 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
19+
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
20+
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
21+
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
22+
//};
23+
const unsigned char PROGMEM wep_keys[] = {};
24+
25+
// Wireless mode
26+
#define WIRELESS_MODE_INFRA 1
27+
#define WIRELESS_MODE_ADHOC 2
28+
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
29+
30+
// Required for the WiShiled library
31+
unsigned char ssid_len;
32+
unsigned char security_passphrase_len;
33+
34+
//-- Constants for the right motor
35+
const int MOTOR_RIGHT = 5;
36+
const int MOTOR_RIGHT_FW = 180; //-- Move the right motor forward
37+
const int MOTOR_RIGHT_BW = 0; //-- Move the right motor backward
38+
const int MOTOR_RIGHT_STOP = 90; //-- Stop the right motor
39+
40+
//-- Constants for the left motor
41+
const int MOTOR_LEFT = 6;
42+
const int MOTOR_LEFT_FW = 0; //-- Move the left motor forward
43+
const int MOTOR_LEFT_BW = 180; //-- Move the left motor backward
44+
const int MOTOR_LEFT_STOP = 90; //-- Stop the left motor
45+
46+
bool strobe = 0;
47+
bool strobe_state = 0;
48+
unsigned char previous_movement=5;
49+
50+
//-- The two motors are servos that can turn freely
51+
Servo rm; //-- Right motor
52+
Servo lm; //-- Left motor
53+
54+
void setup()
55+
{
56+
WiServer.init(sendPage);
57+
rm.attach(MOTOR_RIGHT);
58+
lm.attach(MOTOR_LEFT);
59+
pinMode(4, OUTPUT);
60+
pinMode(7, OUTPUT);
61+
pinMode(8, OUTPUT);
62+
}
63+
64+
void loop()
65+
{
66+
67+
// Run WiServer
68+
if(strobe)
69+
{
70+
if(strobe_state)
71+
{
72+
digitalWrite(4, LOW);
73+
strobe_state=0;
74+
}
75+
else
76+
{
77+
digitalWrite(4, HIGH);
78+
strobe_state=1;
79+
}
80+
}
81+
82+
for(unsigned char i=0; i<10 ; i++)
83+
{
84+
WiServer.server_task();
85+
delay(5);
86+
}
87+
88+
89+
90+
}
91+
92+
void robot_action(unsigned char movement)
93+
{
94+
//movement -> 1 = Front
95+
// 2 = Back
96+
// 3 = Right
97+
// 4 = Left
98+
// 5 = Stop
99+
// 6 = Light on
100+
// 7 = Light off
101+
// 8 = Light Strobe
102+
// 9 = Eyes on
103+
// 10 = Eyes off
104+
105+
switch(movement)
106+
{
107+
case 1:
108+
rm.write(MOTOR_RIGHT_FW);
109+
lm.write(MOTOR_LEFT_FW);
110+
break;
111+
case 2:
112+
rm.write(MOTOR_RIGHT_BW);
113+
lm.write(MOTOR_LEFT_BW);
114+
break;
115+
case 3:
116+
lm.write(MOTOR_LEFT_FW);
117+
rm.write(MOTOR_RIGHT_BW);
118+
break;
119+
case 4:
120+
lm.write(MOTOR_LEFT_BW);
121+
rm.write(MOTOR_RIGHT_FW);
122+
break;
123+
case 5:
124+
rm.write(MOTOR_RIGHT_STOP);
125+
lm.write(MOTOR_LEFT_STOP);
126+
break;
127+
case 6:
128+
digitalWrite(4, HIGH);
129+
break;
130+
case 7:
131+
digitalWrite(4, LOW);
132+
strobe = 0;
133+
break;
134+
case 8:
135+
strobe = 1;
136+
break;
137+
case 9:
138+
digitalWrite(7, HIGH);
139+
digitalWrite(8, HIGH);
140+
break;
141+
case 10:
142+
digitalWrite(7, LOW);
143+
digitalWrite(8, LOW);
144+
break;
145+
}
146+
}
147+
148+
149+
150+
151+
void OurPage(void)
152+
{
153+
WiServer.print("<html><head><title>Robot</title></head>");
154+
155+
WiServer.print("<body><center>Control !<center>\n<center>");
156+
157+
WiServer.print("<a href=?Front>Front</a></br>");
158+
WiServer.print("<a href=?Back>Back</a></br>");
159+
WiServer.print("<a href=?Right>Right</a></br>");
160+
WiServer.print("<a href=?Left>Left</a></br>");
161+
WiServer.print("<a href=?Stop>Stop</a></br>");
162+
WiServer.print("<a href=?LightOn>Light On</a></br>");
163+
WiServer.print("<a href=?LightOff>Light Off</a></br>");
164+
WiServer.print("<a href=?EyesOn>Eyes On</a></br>");
165+
WiServer.print("<a href=?EyesOff>Eyes Off</a></br>");
166+
WiServer.print("<a href=?LightStrobe>Light Strobe</a></br>");
167+
168+
WiServer.print("</html> ");
169+
}
170+
171+
172+
// This is our page serving function that generates web pages
173+
boolean sendPage(char* URL_Received)
174+
{
175+
String URL_String = URL_Received; // Just convert the chat* receivedto a String object
176+
177+
if (URL_String == "/?Front")
178+
{
179+
robot_action(1);
180+
previous_movement=1;
181+
}
182+
else if(URL_String == "/?Back")
183+
{
184+
robot_action(2);
185+
previous_movement=2;
186+
}
187+
else if(URL_String == "/?Right")
188+
{
189+
robot_action(3);
190+
delay(100);
191+
robot_action(previous_movement);
192+
}
193+
else if(URL_String == "/?Left")
194+
{
195+
robot_action(4);
196+
delay(100);
197+
robot_action(previous_movement);
198+
}
199+
else if(URL_String == "/?Stop")
200+
{
201+
robot_action(5);
202+
previous_movement=5;
203+
}
204+
else if(URL_String == "/?LightOn")
205+
{
206+
robot_action(6);
207+
}
208+
else if(URL_String == "/?LightOff")
209+
{
210+
robot_action(7);
211+
}
212+
else if(URL_String == "/?LightStrobe")
213+
{
214+
robot_action(8);
215+
}
216+
else if(URL_String == "/?EyesOn")
217+
{
218+
robot_action(9);
219+
}
220+
else if(URL_String == "/?EyesOff")
221+
{
222+
robot_action(10);
223+
}
224+
else if(URL_String.substring(0,8) == "/?Degree=")
225+
{
226+
227+
}
228+
else
229+
{
230+
// unknown URL
231+
}
232+
233+
OurPage();
234+
235+
return true;
236+
}

Arduino/make.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Applications/Arduino.app/Contents/MacOS/Arduino --verify ~/Desktop/robot2/robot2.ino

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CreeperBot
2+
3+
This is a little remote telepresence robot based on Thingiverse 63165 (http://www.thingiverse.com/thing:63165)
4+
5+
I modified the main body slightly to accomodate larger free rotation servos I had.
6+
7+
I also added a Creeper face with LED eyes and mount for an iPhone 4
8+
9+
This was build as an example in a talk I did for Montreal.rb
10+
11+
# FaceTime AutoAnswer
12+
13+
Unfortunatly there is no way to get FaceTime to auto-answer without Jailbreaking the phone.
14+
15+
Once Jailbroken, simply install the Cydia app called "FaceTime Surveillance"
16+
17+
# Network
18+
19+
As the Arduino does not support HTTPS or any type of security it is not advisable to connect it directly to the internet (unless you make firewall based restrictions).
20+
21+
Therefore a RaspberryPi is put in the mix to provide an abstraction layer
22+
23+
Internet <-----> RaspberryPi <---wifi---> Arduino

RaspberryPi/api/creeperbot_api.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require "sinatra"
2+
require "net/http"
3+
require "rubygems"
4+
5+
RobotIP="10.0.9.44"
6+
7+
get "/LightOn" do
8+
Net::HTTP.get(URI("http://#{RobotIP}/?LightOn"))
9+
end
10+
11+
get "/LightOff" do
12+
Net::HTTP.get(URI("http://#{RobotIP}/?LightOff"))
13+
end
14+
15+
get "/EyesOn" do
16+
Net::HTTP.get(URI("http://#{RobotIP}/?EyesOn"))
17+
end
18+
19+
get "/EyesOff" do
20+
Net::HTTP.get(URI("http://#{RobotIP}/?EyesOff"))
21+
end
22+
23+
get "/LightStrobe" do
24+
Net::HTTP.get(URI("http://#{RobotIP}/?LightStrobe"))
25+
end
26+
27+
get "/Front" do
28+
Net::HTTP.get(URI("http://#{RobotIP}/?Front"))
29+
end
30+
31+
get "/Right" do
32+
Net::HTTP.get(URI("http://#{RobotIP}/?Right"))
33+
end
34+
35+
get "/Left" do
36+
Net::HTTP.get(URI("http://#{RobotIP}/?Left"))
37+
end
38+
39+
get "/Back" do
40+
Net::HTTP.get(URI("http://#{RobotIP}/?Back"))
41+
end
42+
43+
get "/Stop" do
44+
Net::HTTP.get(URI("http://#{RobotIP}/?Stop"))
45+
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.switch-button-label {
2+
float: left;
3+
4+
font-size: 10pt;
5+
cursor: pointer;
6+
}
7+
8+
.switch-button-label.off {
9+
color: #adadad;
10+
}
11+
12+
.switch-button-label.on {
13+
color: #0088CC;
14+
}
15+
16+
.switch-button-background {
17+
float: left;
18+
position: relative;
19+
20+
background: #ccc;
21+
border: 1px solid #aaa;
22+
23+
margin: 1px 10px;
24+
25+
-webkit-border-radius: 4px;
26+
-moz-border-radius: 4px;
27+
border-radius: 4px;
28+
29+
cursor: pointer;
30+
}
31+
32+
.switch-button-button {
33+
position: absolute;
34+
35+
left: -1px;
36+
top : -1px;
37+
38+
background: #FAFAFA;
39+
border: 1px solid #aaa;
40+
41+
-webkit-border-radius: 4px;
42+
-moz-border-radius: 4px;
43+
border-radius: 4px;
44+
}

RaspberryPi/web/css/main.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#main_table{width:100%;} /*or whatever width you want*/
2+
#main_table td{width:2000px;} /*something big*/

RaspberryPi/web/images/down.png

9.6 KB
Loading

RaspberryPi/web/images/left.png

9.64 KB
Loading

RaspberryPi/web/images/right.png

9.6 KB
Loading

RaspberryPi/web/images/stop.jpg

481 KB
Loading

0 commit comments

Comments
 (0)