Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

led controller problem


  • Please log in to reply
8 replies to this topic

#1 ASM71

ASM71

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 02 July 2014 - 02:11 PM

hi,

i am trying to control on board led using webpage but when i request url i got internet explorer can not display webpage attached is the program which i got from book getting started with internet

Attached Files



#2 Joshk

Joshk

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 03 July 2014 - 11:37 PM

I think to make this work you need to first login to your home router and get the address of the netduino plus, probably something a lot like 192.168.1.45 and then you can go to internet explorer and type this: 192.168.1.45/led/target.html

That should pull the webpage from the Netduino Plus.  Does that help?



#3 ASM71

ASM71

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 04 July 2014 - 01:08 AM

hi, Joshk

i am using a fixed ip for netduino i can ping board successfully i am still can not access page

http://172.20.70.200/led/target.html



#4 ASM71

ASM71

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 04 July 2014 - 01:56 AM

hi,

it is working now there was ip confilect between borad and a pc , i have another issue how i can got the status of the onboard led to be displayed with another button or to be displayed when i request uri  http://172.20.70.200/led/target.html



#5 Joshk

Joshk

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 08 July 2014 - 04:16 PM

For this project you may need some help from W3schools.com to learn HTML code.  That way you can modify the webpage script exactly as desired.  But here's the crash course...  You see that variable called 'script' in your netduino code?  That is the HTML sent back to the browser on your computer.  If led.read = true, then between the paragraph tags (<p> and </p>) you could have the text "LED IS ON", and the opposite if false.  Then you will see that same text on your computer's webpage.



#6 ASM71

ASM71

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 11 July 2014 - 03:53 PM

hi,

i update the program to include led status but i got compilier error 

 

Error 1 The name 'OutputPin' does not exist in the current context
 
attached is the modified program

Attached Files



#7 Joshk

Joshk

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 11 July 2014 - 07:16 PM

I'm going to use the most simple way I can think of to make this work so nobody tell me how bad my style is :)  Also I don not really know C# so this will not work without some fixing.

 

 

Replace your 'script' definition with this bit of code...

 

var script = @""; ///Declare it as nothing right now, then set it as after knowing the LED status.

if (Pins.ONBOARD_LED.read == true) {
script = @"<html>
                <head>
                  <script type=""text/javascript"">
                    var r;
                    try {
                      r = new XMLHttpRequest();
                    } catch (e) {
                      r = new ActiveXObject('Microsoft.XMLHTTP');
                    }
                    function put (content) {
                      r.open('PUT', '" + requestUri + @"');
                      r.setRequestHeader('Content-Type', 'text/plain');
                      r.send(content);
                    }
                  </script>
                </head>
                <body>
                  <p>
                    LED IS ON.
                    <input type=""button"" value=""Switch LED on""  
                      onclick=""put('true')""/>
                    <input type=""button"" value=""Switch LED off"" 
                      onclick=""put('false')""/>
                    
                  </p>
                </body>
             </html>";}
else {
script = @"<html>
                <head>
                  <script type=""text/javascript"">
                    var r;
                    try {
                      r = new XMLHttpRequest();
                    } catch (e) {
                      r = new ActiveXObject('Microsoft.XMLHTTP');
                    }
                    function put (content) {
                      r.open('PUT', '" + requestUri + @"');
                      r.setRequestHeader('Content-Type', 'text/plain');
                      r.send(content);
                    }
                  </script>
                </head>
                <body>
                  <p>
                    LED IS OFF.
                    <input type=""button"" value=""Switch LED on""  
                      onclick=""put('true')""/>
                    <input type=""button"" value=""Switch LED off"" 
                      onclick=""put('false')""/>
                    
                  </p>
                </body>
             </html>";}


#8 ASM71

ASM71

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 11 July 2014 - 09:11 PM

hello,

thanks for effort but i am still have copliling error

 

Error 1 'Microsoft.SPOT.Hardware.Cpu.Pin' does not contain a definition for 'read' and no extension method 'read' accepting a first argument of type 'Microsoft.SPOT.Hardware.Cpu.Pin' could be found (are you missing a using directive or an assembly reference?)
 


#9 Joshk

Joshk

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 12 July 2014 - 01:51 AM

If you can't read it then it is probably set up wrong.  In VB.NET you would setup and use the onboard led like this:

            Dim onboardLed As New OutputPort(Pins.ONBOARD_LED, False)

            If onboardLed.Read = True Then
                Debug.Print("Your LED is on.")
            Else
                Debug.Print("Your LED is off.")
            End If





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.