Netduino home hardware projects downloads community

Jump to content

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

Analog Input - Photocell and Webpage

  • Please log in to reply
4 replies to this topic

#1 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 06 December 2010 - 12:17 AM

I made this to show you another way to output your photocell's data. I have spent hours playing with this, don't waste too much time ;). I hope you enjoy this! I'll post the schematics for the photocell here too.

Use the code below with Fred's Web Server code. (http://forums.netdui...ted-web-server/)

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.IO;
using Ethernet.Data;

namespace NetduinoPlusWebServer
    public class Program
        static AnalogInput photcell;

        public static void Main()
            Listener webServer = new Listener(RequestReceived);
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            photcell = new AnalogInput(Pins.GPIO_PIN_A5);

            photcell.SetRange(0, 255);

            while (true)
                // Blink LED to show we're still responsive

        private static void RequestReceived(Request request)
            int shade = photcell.Read();

                "<html>" +
                "<header> <meta http-equiv=\"refresh\" content=\"2\"></header>" +
                "<body style=\"background-color: rgb(" + shade + "," + shade + "," + shade + ")\">" +
                "<p> Time (relative to start time): " + DateTime.Now.ToString() + "</p>" +
                "<p> Value: " + shade + "</p>" +
                "</body>" +


Thanks a bunch for the web server code Fred!

Attached Files

#2 ThingSpeak



  • Members
  • PipPip
  • 13 posts

Posted 27 January 2011 - 06:13 AM

Thanks for the video, it was helpful for me in my tutorial preparation.

#3 Earthed



  • Members
  • PipPip
  • 20 posts
  • LocationAustralia

Posted 30 August 2011 - 11:03 PM

if using 4.2 RC1: take a look at this http://forums.netdui...7292#entry17292

#4 Larsey


    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 06 March 2013 - 08:48 PM

Hello Omar :-)


Silly question, but why is the resistor placed after the photocell and to the ground?

#5 JerseyTechGuy


    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 06 March 2013 - 09:51 PM

Hello Omar :-)


Silly question, but why is the resistor placed after the photocell and to the ground?

This is called a Pull-Down resistor.  You may have heard of Pull-Up resistors.  Pull-Up and Pull-Down resistors are used to put a point in a that may be attached to an input into a defined state as opposed to letting it simply float.  Many designers follow a simple rule of never leaving your inputs floating even ones that have nothing connected to them. But this applies typically to digital inputs to be sure we have clear 0 and 1 states.


For analog inputs, sometimes an input needs a DC bias. This can be done using a simple resistive voltage divider-- which also looks like a pull-up + pull-down. Normally in this case there is also something that is resisting the DC, like a capacitor or in this case the photocell.  The photocell likely has it's own resistive value so the need for the pull-up is not necessary in this case.

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.