A user in the customer forums had a problem with multiplexing analog signals, they seemed to be very noisy and inconsistent. Turns out it was because the sensors are high impedance. This means that if there is capacitance on the ADC line or on any sort of sample&hold capacitor, it may take a while for it to charge up. Read these threads for some great analysis! View here and here…
Sequence of events:
-Detect motion (IR sensor)
-Trigger Silly String (servo)
-Play sound (funny laugh on a $4 Wal-mart toy recorder)
-Transmit RF signal to second Arduino
-Second Arduino receives RF signal
-Wifi shield sends tweet (follow on Twitter: hackolantern)
-Wait 20 seconds before it can shoot again
Longashes (a cigar social network) made a twittering humador… They write -
I know what you’re thinking.. “not another device that tweets something!” Yup, another device that tweets something. This time it’s a humidor and it tweets that status of it’s relative humidity and temperature levels. For cigar aficionados, this means a lot. In order to keep your cigars “fresh” for any amount of time over a few days, they must be contained in an environment that is controlled with the perfect amount of relative humidity and temperature levels. The purpose of this is so that your cigars don’t dry out or get too moist which would amount to a terrible smoking experience. The Tweetidor uses a digital precision relative humidity and temperature sensor (SHT75) along with the arduino.
PIR sensors allow you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and don’t wear out. For that reason they are commonly found in appliances and gadgets used in homes or businesses. They are often referred to as PIR, “Passive Infrared”, “Pyroelectric”, or “IR motion” sensors.
PIRs are basically made of a pyroelectric sensor (which you can see above as the round metal can with a rectangular crystal in the center), which can detect levels of infrared radiation. Everything emits some low level radiation, and the hotter something is, the more radiation is emitted. The sensor in a motion detector is actually split in two halves. The reason for that is that we are looking to detect motion (change) not average IR levels. The two halves are wired up so that they cancel each other out. If one half sees more or less IR radiation than the other, the output will swing high or low.
Along with the pyroelectic sensor is a bunch of supporting circuitry, resistors and capacitors. It seems that most small hobbyist sensors use the (BISS0001 (“Micro Power PIR Motion Detector IC”), undoubtedly a very inexpensive chip. This chip takes the output of the sensor and does some minor processing on it to emit a digital output pulse from the analog sensor.
For many basic projects or products that need to detect when a person has left or entered the area, or has approached, PIR sensors are great. They are low power and low cost, pretty rugged, have a wide lens range, and are easy to interface with. Note that PIRs won’t tell you how many people are around or how close they are to the sensor, the lens is often fixed to a certain sweep and distance (although it can be hacked somewhere) and they are also sometimes set off by housepets. Experimentation is key!
PIR sensors are used to detect motion from pets/humanoids from about 20 feet away (possibly works on zombies, not guaranteed). Usually this sensor comes with a straight 3-pin header soldered on. This makes it annoying to use because its is not easy to plug into a breadboard and you can’t solder wires in. So we requested to leave it off and include a 3-pin right-angle header instead which you can solder in for breadboard use or skip and use wires. Runs on 3.3-6V. Digital signal output is high/low. In the shop now, $10 !
Flex (bend) sensor! This sensor can detect bending in one direction. They were popularized by being used in the Nintendo PowerGlove as a gaming interface. These sensors are easy to use, they are basically resistors that change value based on how much their flexed. If they’re unflexed, the resistance is about ~10KΩ. When flexed all the way the resistance rises to ~20KΩ. They’re pretty similar to FSRs so following this tutorial will get you started. You can use an analog input on a microcontroller (with a pullup resistor) or a digital input with the use of a 0.1uF capacitor for RC timing. Flex (bend) sensor, in the Adafruit store.
The MaxSonar EZ1 provides very short to long-range detection and ranging, in an incredibly small package. It can detect objects from 0-inches to 254-inches (6.45-meters) and provides sonar range information from 6-inches out to 254-inches with 1-inch resolution. (Objects from 0 inches to 6-inches range as 6-inches.) The interface output formats included are pulse width output (PWM), analog voltage output (Vcc/512 volts per inch), and serial digital output (9600 baud). A good sensor for when a Sharp IR distance sensor won’t cut it.
Solder it up!
Solder 3 wires to the Maxbotix sonar sensor. Ground, power and analog. That’s all we’ll need for this simple test, and for the most part if you’re just using this sensor with an Arduino it’s all you’ll likely use.
Wire it up!
For this example we’re going to use a half size bread board, some wires and a piezo buzzer with the MaxSonar and Arduino.
Run some code!
The MaxSonar EZ1 outputs analog voltage with a scaling factor of (Vcc/512) per inch. A supply of 5V yields ~9.8mV per inch. On the other hand, the Arduino’s analog-to-digital converter (ADC) has a range of 1024, which means each bit is ~4. 9mV. For that reason, to convert the number returned by the ADC to inches, we have to divide by 2.
// using the maxsonar quick start http://www.adafruit.com// http://www.adafruit.com/index.php?main_page=product_info&cPath=35&products_id=172int sonarPin = 0; //pin connected to analog out on maxsonar sensorint piezoPin = 9;
int inchesAway;
voidsetup() {
pinMode(piezoPin, OUTPUT);
}
voidloop() {
inchesAway = analogRead(sonarPin) /2;
if (inchesAway < 24) { // if something is 24 inches away then make a 1khz sounddigitalWrite(piezoPin, HIGH);
delayMicroseconds(500);
digitalWrite(piezoPin, LOW);
delayMicroseconds(500);
}
}
What is a photocell?
Photocells are sensors that allow you to detect light. They are small, inexpensive, low-power, easy to use and don’t wear out. For that reason they often appear in toys, gadgets and appliances. Theys are are often refered to a CdS cells (they are made of Cadmium-Sulfide), light-dependent resistors (LDR), and photoresistors.
Photocells are basically a resistor that changes its resistive value (in ohms Ω) depending on how much. They are very low cost, easy to get in many sizes and specifications, but are very innacurate. Each photocell sensor will act a little differently than the other, even if they are from the same batch. The variations can be really large, 50% or higher! For this reason, they shouldn’t be used to try to determine precise light levels in lux or millicandela. Instead, you can expect to only be able to determine basic light changes.
For most light-sentsitive applications like “is it light or dark out”, “is there something in front of the sensor (that would block light)”, “is there something interrupting a laser beam” (break-beam sensors), or “which of multiple sensors has the most light hitting it”, photocells can be a good choice!
Some basic stats
These stats are for the photocell in the Adafruit shop which is very much like the PDV-P8001. Nearly all photocells will have slightly different specifications, although they all pretty much work the same. If there’s a datasheet, you’ll want to refer to it
Size: Round, 5mm (0.2″) diameter. (Other photocells can get up to 11mm/0.4″ diameter!)
How to measure light using a photocell
As we’ve said, a photocell’s resistance changes as the face is exposed to more light. When its dark, the sensor looks like an large resistor up to 10MΩ, as the light level increases, the resistance goes down. This graph indicates approximately the resistance of the sensor at different light levels. Remember each photocell will be a little different so use this as a guide only!