├── .gitignore
├── README.markdown
├── explanation.jpg
├── github_mockuppsd.jpg
├── github_test.html
├── github_test_fail.html
└── stoplight_firmware
└── stoplight_firmware.pde
/.gitignore:
--------------------------------------------------------------------------------
1 | *.psd
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | GitHub Spotlight Project
2 | ========================
3 |
4 | Spec
5 | --------
6 |
7 | Connect the GitHub Spotlight to a microcontroller so it can be controlled by the GitHub continuous integration system.
8 |
9 | Proposal
10 | ------------
11 |
12 | I intend to use the [Black Widow Arduino](http://asynclabs.com/store?page=shop.product_details&flypage=flypage.tpl&product_id=23&category_id=11&keyword=wifi) to control three relays to turn on and off each of the stoplight's lights. The Black Widow comes with a built-in wifi antenna so I will be able to make it controllable via a web interface accessible via the local network.
13 |
14 | 
15 |
16 | The relays and arduino will fit inside the existing stoplight case.
17 |
18 | 
19 |
20 | The only possible necessary modification will be to drill a hole for the power supply cord.
21 |
22 | Budget
23 | ----------
24 |
25 | * $75 Black Widow Arduino
26 | * $36 3x Sparkfun Relay Control w/ PCB ($12 ea.)
27 | * $5 9V wall wart for Arduino
28 |
29 | Total: $116
--------------------------------------------------------------------------------
/explanation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atduskgreg/GitHub-Stoplight/bfee1dc21f0bf4a21c302e222f6d6d2b0858c256/explanation.jpg
--------------------------------------------------------------------------------
/github_mockuppsd.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/atduskgreg/GitHub-Stoplight/bfee1dc21f0bf4a21c302e222f6d6d2b0858c256/github_mockuppsd.jpg
--------------------------------------------------------------------------------
/github_test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Up
4 |
5 |
--------------------------------------------------------------------------------
/github_test_fail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Fail
4 |
5 |
--------------------------------------------------------------------------------
/stoplight_firmware/stoplight_firmware.pde:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int red = 2;
5 | int yellow = 3;
6 | int green = 4;
7 |
8 | byte mac[] = {
9 | 0x00, 0x26, 0x4a, 0x14, 0x7F, 0x9F };
10 | byte ip[] = {
11 | 192,168,1,147 };
12 | byte server[] = {
13 | 207,97,227,239}; // github.com
14 |
15 | #define maxResponseLength 1000
16 |
17 | String response = String(maxResponseLength);
18 |
19 | int notConnectedMode = 0;
20 | int connectedMode = 1;
21 | int mode = 0;
22 |
23 | int ethernetResetPin = 6;
24 |
25 | int pingInterval = 5 * 1000;
26 | unsigned long lastPingTime = 0;
27 |
28 | int currentLight = red;
29 |
30 |
31 | Client client(server, 80);
32 |
33 | void setup()
34 | {
35 |
36 | pinMode(red, OUTPUT);
37 | pinMode(yellow, OUTPUT);
38 | pinMode(green, OUTPUT);
39 | pinMode(ethernetResetPin, OUTPUT);
40 | digitalWrite(ethernetResetPin, LOW);
41 | delay(500);
42 | digitalWrite(ethernetResetPin, HIGH);
43 |
44 | Ethernet.begin(mac, ip);
45 | Serial.begin(9600);
46 |
47 | delay(1000);
48 | }
49 |
50 | void loop()
51 | {
52 | digitalWrite(currentLight, HIGH);
53 |
54 | if((millis() - lastPingTime) >= pingInterval){
55 | // time to ping
56 | doCheck();
57 | }
58 |
59 |
60 |
61 |
62 | }
63 |
64 | void doCheck(){
65 | if(mode == notConnectedMode){
66 | // try to connect
67 | Serial.println("connecting...");
68 | if (client.connect()) {
69 | Serial.println("connected");
70 | client.println("GET /site/stoplight/ HTTP/1.0");
71 | client.println();
72 | mode = connectedMode;
73 | }
74 | else {
75 | Serial.println("connection failed");
76 | delay(2000);
77 | Serial.println("trying again...");
78 | }
79 |
80 | }
81 | // in connectedMode
82 | else {
83 | if (client.available()) {
84 | char c = client.read();
85 | Serial.print(c);
86 | response.append(c);
87 | }
88 |
89 | if (!client.connected()) {
90 | lastPingTime = millis();
91 | // TODO: change this to 412
92 | if(response.contains("HTTP/1.1 412 ")){
93 | if(response.contains("building")){
94 | Serial.println("YELLOW - 412");
95 | currentLight = yellow;
96 | digitalWrite(yellow, HIGH);
97 | digitalWrite(red, LOW);
98 | digitalWrite(green, LOW);
99 | }
100 | else {
101 | Serial.println("RED - 412");
102 | currentLight = red;
103 | digitalWrite(red, HIGH);
104 | digitalWrite(yellow, LOW);
105 | digitalWrite(green, LOW);
106 | }
107 |
108 | }
109 | else if(response.contains("HTTP/1.1 200")){
110 | Serial.println("GREEN - 200");
111 | currentLight = green;
112 | digitalWrite(green, HIGH);
113 | digitalWrite(red, LOW);
114 | digitalWrite(yellow, LOW);
115 | }
116 | Serial.println();
117 | Serial.println("disconnecting.");
118 | client.stop();
119 |
120 | response = "";
121 | mode = notConnectedMode;
122 | digitalWrite(ethernetResetPin, LOW);
123 | delay(500);
124 | digitalWrite(ethernetResetPin, HIGH);
125 |
126 | Ethernet.begin(mac, ip);
127 | //delay(5000);
128 | }
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------