Photo resistor as on/off switch

Hi y'all,

I have a question about the appropriateness of a photo resistor as an on/off switch for an art project. I'm really new to Arduino stuff but it's really interesting to me and it's fun to figure out new ways to use it.
The idea is that I have an LCD screen that has a text that scrolls across it—turned on by someone walking near it, then off by the absence of a person. I've got the code figured out for that, but I need to figure out:
A) what kind of sensor I should use to switch it on/off (sonar, photo resistor?)
B) how to include that code in with the code I already have figured out for the LCD screen thing.

Please let me know your thoughts and/or ideas!

Thanks,

Kaleigh

text scroll.rtf (1.91 KB)

Sensing with environmental information is really tricky...

But first, choosing which types of sensors to use is a decision best left up to you. Consider how the environment works. Are there lots of cars going by that reflect sunlight in and strange hours? Is the sonar in a place which will bother native wildlife (bats, marine mammals, etc.)? Just consider what's probably around there, and your answer will present itself.

The code is very simple. It's either going to be a PWM (pulse-width modulation) signal (as with the sonar) or it's going to be a digital signal (as with a simple photosensor). You might even get tricky with a photoresistor (which sends a PWM signal based on the available level of light), and limit it to certain inputs. Or, you could buy a cheap CMOS camera and have it look for specific color values. There are just so MANY possibilities that the choice can seem overwhelming.

But in the end, it's just a choice. And the choice is yours.

An ultrasonic sensor would be the easiest way...

But an ldr could be used to detect fluctuations in light and I've seen this method work well.

I would use a distance sensor like this one from Pololu.

That way, when someone is within a certain distance you your project, it ca turn on.

Why not use a security type ir sensor, close range ones can be had, they detect movement though so someone standing still for a while it would turn off.

They can detect a starionary person however if you use a mechanical or lcd chopper.

If you have ever seen Spooks you will have seen the entry pods.
They a real and can detect the difference of 2 people present, find out how they work.

Here are some more specific questions:

  1. What type of area will it be? Is it inside or outside? Will it be light or dark?
  2. How close do you want a person to be before it turns on?
  3. What kind of sensing arc do you need? Does it need to sense within 180degrees, 360? Or if you pass a small line is that okay?
  4. Do you need to be able to adjust all of these things?
  5. Are there any aesthetic issues that you are worried about?

Is there a carpet ?

http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf

Poached from a new thread

RedHeron:
I think that I'm going to go with a sonar sensor. I talked to my professor and he thinks that's going to be our best bet. I'm kind of an actual n00b so I'm kind of having a difficult time conceptualizing where the code will go when I add it. I have it so it scrolls and stuff but I seriously have no idea how to add the sonar on/off switch... uuugggghhhh.

cjdelphi:
Thanks! Yeah, I'm gonna go with the ultrasonic sensor. :slight_smile:

Pauly:
Yeah, I'm hoping to get that effect.

Boardburner2:
Yeah, there is a carpet. I'm going to use the ultrasonic sensor. Thanks for the thermal sensor link—looks pretttty cool.

Mirith:

  1. It's going to be in a foyer inside. It'll be slightly naturally lit during the day and dark at night, but I'm not really worried about nighttime.
  2. The foyer is rather small, so the person would really only need to be like 5 feet away.
  3. I don't know what that means!
  4. I don't need to be able to adjust it. The idea is that I just set it up and then can leave it and it turns on when someone is nearby and shuts off after an amount of time (or after the person leaves).
  5. Aesthetic issues I'm not so worried about. I'm going to use a 3D printer to create an encasement for the thing but I don't care whether it looks cool or is obvious or whatever.

This would depend on which sonar switch you decided on. Generally, though, it's going to be a read-only input (the only thing you can do is to open the circuit to read it or close the circuit to stop reading it).

The signal is activated with either analogRead() or digitalRead(), and I would HIGHLY recommend reading up on those in the reference section on this site. It reads like stereo instructions at first (I mean, really, who understands those?) but once you just follow the instructions and see how it all works, it'll be really sensible how it works or not.

Also, look at the code examples in the Arduino IDE... they're VERY instructive and will show you a lot of things that are just good practices. Not everyone's code agrees... most will tell you to F() your Strings, but some will say this isn't a great idea (and truly, the answer depends on the chip at the core of the board you're using... if an Uno or anything with a 328 chip, F() those Strings!).

While you're learning, make EXTENSIVE use of the reference on this site. It's updated regularly and has a LOT of truly helpful information, but it takes putting it into practice before it actually makes sense... so because this is a "prototyping platform" the real nature of this hardware is experimentation.

In other words: play! Try out things. Dive right into it headlong. And soon you'll be an old pro, hacking away with the best of the people on this site. I mean, really: I've only been at Arduino for like 2 months, but I've been programming for years and so the software side of things is cake to me. And Arduino is like learning to speak Australian or Cockney or Ebonics... once you learn it, it's really just the same language that everything else uses, with stricter rules on some things and more flexible rules on other things. It's like a culture. Except, you know, in code.

But not all boring like I made it sound. I promise.

So... to recap:

  1. Look up digitalRead() and analogRead().
  2. Look up F() and print() and println() (and related functions).
  3. Look up the code in the examples in the Arduino software.
  4. Experiment around, play, and even break software stuff. But do be careful not to damage the hardware... it gets expensive after the fifteenth board fries in a month.
  5. Above all, having fun with this is kinda mandatory. Not everyone on here is nice, but I try to at least offer being pleasant before anything else.

Hope this helps!

Also: "Sensing arc" is actually a role-playing gaming term that got applied to engineering, reapplied to gaming, and re-reapplied to engineering again... the term means "the range and angle that the sensor can see within" and it's something you need to think about when choosing a sonar (or any other kind of) sensor.

Just trying to be helpful. Again. Some more.