Skip to content

Commit

Permalink
Arduino code update
Browse files Browse the repository at this point in the history
  • Loading branch information
joepenzo committed Apr 27, 2012
1 parent af92477 commit d31a8f6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 38 deletions.
Expand Up @@ -11,7 +11,8 @@ byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(80); //server port Server server(80); //server port
String readString = String(30); //string for fetching data from address String readString = String(30); //string for fetching data from address


dht11 tempSensor; dht11 DHT11;
#define DHT11PIN A3


#define action_none -1 #define action_none -1
#define action_status 0 #define action_status 0
Expand All @@ -26,7 +27,6 @@ dht11 tempSensor;
#define action_off_all 8 #define action_off_all 8
#define change_rbg 9 #define change_rbg 9


#define tempPin A5
// arduino out // arduino out
int led1 = 2; int led1 = 2;
int led2 = 3; int led2 = 3;
Expand Down Expand Up @@ -69,10 +69,11 @@ void setup(){
pinMode(greenPin, OUTPUT); pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT); pinMode(bluePin, OUTPUT);


current_action = -1; current_action = -1;
} }


void loop(){ void loop(){

current_action = -1; current_action = -1;


// Create a client connection // Create a client connection
Expand Down Expand Up @@ -137,6 +138,7 @@ void loop(){
switch(current_action) switch(current_action)
{ {
case action_status: case action_status:
DHT11.read(DHT11PIN); // read temp sensor
client.print("{\"ip\" : \"192.168.1.100\", \"lights\" : [{ \"status\" : \""); client.print("{\"ip\" : \"192.168.1.100\", \"lights\" : [{ \"status\" : \"");
client.print(digitalRead(led1)); client.print(digitalRead(led1));
client.print("\", \"out\" : \""); client.print("\", \"out\" : \"");
Expand All @@ -152,9 +154,9 @@ void loop(){
client.print("\" , \"out\" : \""); client.print("\" , \"out\" : \"");
client.print(led3); client.print(led3);
client.print("\"}] , \"temperature\" : [{ \"temp\" : \""); client.print("\"}] , \"temperature\" : [{ \"temp\" : \"");
client.print("100");//print temp in celcius client.print((float)DHT11.temperature, 1);
client.print("\"}, {\"humidity\" : \""); client.print("\"}, {\"humidity\" : \"");
client.print("50"); //print humidity client.print((float)DHT11.humidity, 0);
client.print("\"}]}"); client.print("\"}]}");
break; break;
case action_on_led1: case action_on_led1:
Expand Down Expand Up @@ -281,6 +283,8 @@ int8_t charToInt( char *str ){
return r; return r;
} }






void writeRGBValue(int red, int green, int blue){ void writeRGBValue(int red, int green, int blue){
analogWrite(redPin, red*10); // set the LED on analogWrite(redPin, red*10); // set the LED on
Expand Down
52 changes: 26 additions & 26 deletions webclient/webpage/Webserver/arduinoControll.iws
Expand Up @@ -58,19 +58,19 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <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"> <entry file="file://$PROJECT_DIR$/mobile/index.php">
<provider selected="true" editor-type-id="text-editor"> <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 /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </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"> <entry file="file://$PROJECT_DIR$/mobile/js/end_script.js">
<provider selected="true" editor-type-id="text-editor"> <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 /> <folding />
</state> </state>
</provider> </provider>
Expand All @@ -79,7 +79,7 @@
<file leaf-file-name="start_script.js" pinned="false" current="false" current-in-tab="false"> <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"> <entry file="file://$PROJECT_DIR$/mobile/js/start_script.js">
<provider selected="true" editor-type-id="text-editor"> <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 /> <folding />
</state> </state>
</provider> </provider>
Expand All @@ -88,7 +88,7 @@
<file leaf-file-name="style.css" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="style.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/mobile/style.css"> <entry file="file://$PROJECT_DIR$/mobile/style.css">
<provider selected="true" editor-type-id="text-editor"> <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 /> <folding />
</state> </state>
</provider> </provider>
Expand Down Expand Up @@ -118,9 +118,9 @@
<option value="$PROJECT_DIR$/mobile/arduinorgbrequest.php" /> <option value="$PROJECT_DIR$/mobile/arduinorgbrequest.php" />
<option value="$PROJECT_DIR$/mobile/arduinostatusrequest.php" /> <option value="$PROJECT_DIR$/mobile/arduinostatusrequest.php" />
<option value="$PROJECT_DIR$/mobile/style.css" /> <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/js/start_script.js" />
<option value="$PROJECT_DIR$/mobile/index.php" /> <option value="$PROJECT_DIR$/mobile/index.php" />
<option value="$PROJECT_DIR$/mobile/js/end_script.js" />
</list> </list>
</option> </option>
</component> </component>
Expand Down Expand Up @@ -352,17 +352,6 @@
<option name="PhingTarget" enabled="false" /> <option name="PhingTarget" enabled="false" />
</method> </method>
</configuration> </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"> <configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" runner="idea" /> <extension name="coverage" enabled="false" merge="false" runner="idea" />
<module name="" /> <module name="" />
Expand Down Expand Up @@ -390,6 +379,17 @@
<option name="PhingTarget" enabled="false" /> <option name="PhingTarget" enabled="false" />
</method> </method>
</configuration> </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" /> <list size="0" />
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false"> <configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host> <Host>localhost</Host>
Expand Down Expand Up @@ -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="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="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="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="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="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="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="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" /> <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" />
Expand Down Expand Up @@ -587,28 +587,28 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/mobile/style.css"> <entry file="file://$PROJECT_DIR$/mobile/style.css">
<provider selected="true" editor-type-id="text-editor"> <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 /> <folding />
</state> </state>
</provider> </provider>
</entry> </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"> <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 /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/mobile/js/start_script.js"> <entry file="file://$PROJECT_DIR$/mobile/js/start_script.js">
<provider selected="true" editor-type-id="text-editor"> <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 /> <folding />
</state> </state>
</provider> </provider>
</entry> </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"> <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 /> <folding />
</state> </state>
</provider> </provider>
Expand Down
2 changes: 1 addition & 1 deletion webclient/webpage/Webserver/mobile/index.php
Expand Up @@ -44,7 +44,7 @@
<div id='picked_color'> </div> <div id='picked_color'> </div>
<div id='picked_color_preview'> </div> <div id='picked_color_preview'> </div>
<div id='rgb_submitbutton_holder'> <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>
</div> </div>
Expand Down
25 changes: 19 additions & 6 deletions webclient/webpage/Webserver/mobile/js/end_script.js
Expand Up @@ -7,6 +7,10 @@ var red = sliderStartVal;
var green = sliderStartVal; var green = sliderStartVal;
var blue= sliderStartVal; var blue= sliderStartVal;


var redPicker;
var greenPicker;
var bluePicker;



function updateColor(){ function updateColor(){


Expand Down Expand Up @@ -59,6 +63,15 @@ function requestRGB() {
}, 'json'); }, '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) { function zeroPad(num,count) {
var numZeropad = num + ''; var numZeropad = num + '';
while(numZeropad.length < count) { while(numZeropad.length < count) {
Expand Down Expand Up @@ -221,8 +234,8 @@ function createRGB(jSonData) {


function createTemperature(jSonData) { function createTemperature(jSonData) {
var type = 'temperature'; var type = 'temperature';
var tempStatus = '19'; var tempStatus = jSonData.temperature[0].temp;
var humStatus = '60'; var humStatus = jSonData.temperature[1].humidity;
createCollapsibleContent(type); createCollapsibleContent(type);


$("<h3/>", { $("<h3/>", {
Expand Down Expand Up @@ -320,10 +333,10 @@ $('#canvas_picker').bind('mousemove', function(event){
var y = event.pageY - event.currentTarget.offsetTop; var y = event.pageY - event.currentTarget.offsetTop;
var ctx = document.getElementById('canvas_picker').getContext('2d'); var ctx = document.getElementById('canvas_picker').getContext('2d');
var img_data = ctx.getImageData(x, y, 1, 1).data; var img_data = ctx.getImageData(x, y, 1, 1).data;
var R = img_data[0]; redPicker = img_data[0];
var G = img_data[1]; greenPicker = img_data[1];
var B = img_data[2]; bluePicker = img_data[2];
rgb = 'rgb('+R+','+G+','+B+')'; rgb = 'rgb('+redPicker+','+greenPicker+','+bluePicker+')';
$('#picked_color_preview').css('background-color', rgb); $('#picked_color_preview').css('background-color', rgb);
}); });


Expand Down

0 comments on commit d31a8f6

Please sign in to comment.