Permalink
Browse files

Arduino code update

  • Loading branch information...
1 parent af92477 commit d31a8f6171ba0664b78f89fe38393f4afda33cd9 @joepenzo committed Apr 26, 2012
@@ -11,7 +11,8 @@ byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(80); //server port
String readString = String(30); //string for fetching data from address
-dht11 tempSensor;
+dht11 DHT11;
+#define DHT11PIN A3
#define action_none -1
#define action_status 0
@@ -26,7 +27,6 @@ dht11 tempSensor;
#define action_off_all 8
#define change_rbg 9
-#define tempPin A5
// arduino out
int led1 = 2;
int led2 = 3;
@@ -69,10 +69,11 @@ void setup(){
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
- current_action = -1;
+ current_action = -1;
}
void loop(){
+
current_action = -1;
// Create a client connection
@@ -137,6 +138,7 @@ void loop(){
switch(current_action)
{
case action_status:
+ DHT11.read(DHT11PIN); // read temp sensor
client.print("{\"ip\" : \"192.168.1.100\", \"lights\" : [{ \"status\" : \"");
client.print(digitalRead(led1));
client.print("\", \"out\" : \"");
@@ -152,9 +154,9 @@ void loop(){
client.print("\" , \"out\" : \"");
client.print(led3);
client.print("\"}] , \"temperature\" : [{ \"temp\" : \"");
- client.print("100");//print temp in celcius
+ client.print((float)DHT11.temperature, 1);
client.print("\"}, {\"humidity\" : \"");
- client.print("50"); //print humidity
+ client.print((float)DHT11.humidity, 0);
client.print("\"}]}");
break;
case action_on_led1:
@@ -281,6 +283,8 @@ int8_t charToInt( char *str ){
return r;
}
+
+
void writeRGBValue(int red, int green, int blue){
analogWrite(redPin, red*10); // set the LED on
@@ -58,19 +58,19 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="index.php" pinned="false" current="true" current-in-tab="true">
+ <file leaf-file-name="index.php" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/mobile/index.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="69" column="19" selection-start="2165" selection-end="3229" vertical-scroll-proportion="0.7829233">
+ <state line="46" column="110" selection-start="1710" selection-end="1731" vertical-scroll-proportion="-6.875">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="end_script.js" pinned="false" current="false" current-in-tab="false">
+ <file leaf-file-name="end_script.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/mobile/js/end_script.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="285" column="0" selection-start="8691" selection-end="9239" vertical-scroll-proportion="-5.4545455">
+ <state line="322" column="45" selection-start="9755" selection-end="9755" vertical-scroll-proportion="0.47750363">
<folding />
</state>
</provider>
@@ -79,7 +79,7 @@
<file leaf-file-name="start_script.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/mobile/js/start_script.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="58" column="7" selection-start="1509" selection-end="1899" vertical-scroll-proportion="-10.545455">
+ <state line="58" column="7" selection-start="1509" selection-end="1899" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -88,7 +88,7 @@
<file leaf-file-name="style.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/mobile/style.css">
<provider selected="true" editor-type-id="text-editor">
- <state line="46" column="14" selection-start="771" selection-end="771" vertical-scroll-proportion="-12.545455">
+ <state line="46" column="14" selection-start="771" selection-end="771" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -118,9 +118,9 @@
<option value="$PROJECT_DIR$/mobile/arduinorgbrequest.php" />
<option value="$PROJECT_DIR$/mobile/arduinostatusrequest.php" />
<option value="$PROJECT_DIR$/mobile/style.css" />
- <option value="$PROJECT_DIR$/mobile/js/end_script.js" />
<option value="$PROJECT_DIR$/mobile/js/start_script.js" />
<option value="$PROJECT_DIR$/mobile/index.php" />
+ <option value="$PROJECT_DIR$/mobile/js/end_script.js" />
</list>
</option>
</component>
@@ -352,17 +352,6 @@
<option name="PhingTarget" enabled="false" />
</method>
</configuration>
- <configuration default="true" type="JavascriptDebugSession" factoryName="Local">
- <JSDebuggerConfigurationSettings>
- <option name="engineId" value="embedded" />
- <option name="fileUrl" />
- </JSDebuggerConfigurationSettings>
- <method>
- <option name="AntTarget" enabled="false" />
- <option name="BuildArtifacts" enabled="false" />
- <option name="Maven.BeforeRunTask" enabled="false" />
- </method>
- </configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" runner="idea" />
<module name="" />
@@ -390,6 +379,17 @@
<option name="PhingTarget" enabled="false" />
</method>
</configuration>
+ <configuration default="true" type="JavascriptDebugSession" factoryName="Local">
+ <JSDebuggerConfigurationSettings>
+ <option name="engineId" value="embedded" />
+ <option name="fileUrl" />
+ </JSDebuggerConfigurationSettings>
+ <method>
+ <option name="AntTarget" enabled="false" />
+ <option name="BuildArtifacts" enabled="false" />
+ <option name="Maven.BeforeRunTask" enabled="false" />
+ </method>
+ </configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
@@ -438,10 +438,10 @@
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
- <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25287357" sideWeight="0.46622518" order="1" side_tool="true" content_ui="tabs" />
+ <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.14152299" sideWeight="0.47682118" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25287357" sideWeight="0.5245033" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.14152299" sideWeight="0.5139073" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@@ -587,28 +587,28 @@
</entry>
<entry file="file://$PROJECT_DIR$/mobile/style.css">
<provider selected="true" editor-type-id="text-editor">
- <state line="46" column="14" selection-start="771" selection-end="771" vertical-scroll-proportion="-12.545455">
+ <state line="46" column="14" selection-start="771" selection-end="771" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/mobile/js/end_script.js">
+ <entry file="file://$PROJECT_DIR$/mobile/index.php">
<provider selected="true" editor-type-id="text-editor">
- <state line="285" column="0" selection-start="8691" selection-end="9239" vertical-scroll-proportion="-5.4545455">
+ <state line="46" column="110" selection-start="1710" selection-end="1731" vertical-scroll-proportion="-6.875">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/mobile/js/start_script.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="58" column="7" selection-start="1509" selection-end="1899" vertical-scroll-proportion="-10.545455">
+ <state line="58" column="7" selection-start="1509" selection-end="1899" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/mobile/index.php">
+ <entry file="file://$PROJECT_DIR$/mobile/js/end_script.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="69" column="19" selection-start="2165" selection-end="3229" vertical-scroll-proportion="0.7829233">
+ <state line="322" column="45" selection-start="9755" selection-end="9755" vertical-scroll-proportion="0.47750363">
<folding />
</state>
</provider>
@@ -44,7 +44,7 @@
<div id='picked_color'> </div>
<div id='picked_color_preview'> </div>
<div id='rgb_submitbutton_holder'>
- <input id="rbg_colorpicker_button" type="submit" value="Submit" data-theme="a"/>
+ <input id="rbg_colorpicker_button" type="submit" value="Submit" onclick="requestRGBColorPicker()" data-theme="a"/>
</div>
</div>
@@ -7,6 +7,10 @@ var red = sliderStartVal;
var green = sliderStartVal;
var blue= sliderStartVal;
+var redPicker;
+var greenPicker;
+var bluePicker;
+
function updateColor(){
@@ -59,6 +63,15 @@ function requestRGB() {
}, 'json');
}
+
+
+function requestRGBColorPicker() {
+ console.log("dikkkeshit");
+ $.get("arduinorgbrequest.php", { ip: localStorage.getItem("arduino_ip") , port: localStorage.getItem("arduino_port"), r: redPicker , g: greenPicker, b: bluePicker }, function(data){
+
+ }, 'json');
+}
+
function zeroPad(num,count) {
var numZeropad = num + '';
while(numZeropad.length < count) {
@@ -221,8 +234,8 @@ function createRGB(jSonData) {
function createTemperature(jSonData) {
var type = 'temperature';
- var tempStatus = '19';
- var humStatus = '60';
+ var tempStatus = jSonData.temperature[0].temp;
+ var humStatus = jSonData.temperature[1].humidity;
createCollapsibleContent(type);
$("<h3/>", {
@@ -320,10 +333,10 @@ $('#canvas_picker').bind('mousemove', function(event){
var y = event.pageY - event.currentTarget.offsetTop;
var ctx = document.getElementById('canvas_picker').getContext('2d');
var img_data = ctx.getImageData(x, y, 1, 1).data;
- var R = img_data[0];
- var G = img_data[1];
- var B = img_data[2];
- rgb = 'rgb('+R+','+G+','+B+')';
+ redPicker = img_data[0];
+ greenPicker = img_data[1];
+ bluePicker = img_data[2];
+ rgb = 'rgb('+redPicker+','+greenPicker+','+bluePicker+')';
$('#picked_color_preview').css('background-color', rgb);
});

0 comments on commit d31a8f6

Please sign in to comment.