FRIENDz

FAILURE IS THE SIGN OF SUCCESS!!

Detecting Vibration

Arduino-Detecting Vibration

           A Piezo sensor, also known as a knock sensor, produces a voltage in response to physical stress. The more it is stressed, the higher the voltage. The Piezo is polarized and the positive side (usually a red wire or a wire marked with a “+”) is connected to the analog input; the negative wire (usually black or marked with a “-”) is connected to ground. A high-value resistor (1 megohm) is connected across the sensor.
The voltage is detected by Arduino analogRead to turn on an LED. The THRESHOLD value determines the level from the sensor that will turn on the LED, and you can decrease or increase this value to
make the sketch more or less sensitive. Piezo sensors can be bought in plastic cases or as bare metal disks

Measuring Distance

Arduino-Measuring Distance using PING:
             Ultrasonic sensors provide a measurement of the time it takes for sound to bounce off an object and return to the sensor. The “ping” sound pulse is generated when the pingPin level goes HIGH for two microseconds. The sensor will then generate a pulse that terminates when the sound returns. The width of the pulse is proportional to the distance the sound traveled and the sketch then uses the pulseIn function to measure that duration. The speed of sound is 340 meters per second, which is 29 microseconds per centimeter. The formula for the distance of the round trip is: RoundTrip = microseconds / 29.So, the formula for the one-way distance in centimeters is: microseconds / 29 / 2.

Detecting Motion using Arduino

Detecting Motion-Integrating Passive Infrared Detectors
             This code is similar to the pushbutton. That’s because the sensor acts like a switch when motion is detected. Different kinds of PIR sensors are available, and you should check the information for the one you have connected. Some sensors, such as the Parallax, have a jumper that determines how the output behaves when motion is detected. In one mode, the output remains HIGH while motion is detected, or it can be set so that the output goes HIGH briefly and then LOW when triggered. The example sketch in this recipe’s Solution will work in either mode. Other sensors may go LOW on detecting motion. If your sensor’s output

Detecting Light using Arduino

AVR Arduino-Detecting Light:
       The circuit for this recipe is the standard way to use any sensor that changes its resistance based on some physical phenomenon. The circuit in will change the voltage on analog pin 0 when the resistance of the LDR changes with varying light levels. A circuit such as this will not give the full range of possible values from the analog input—0 to 1,023—as the voltage will not be swinging from 0 volts to 5 volts. This is because there will always be a voltage drop across each resistance, so the voltage where they meet will never reach the limits of the power supply. When using sensors such as these, it is important to check the actual values

Detecting Movement using ARDUINO

AVR-Detecting Movement:
          The most common tilt sensor is a ball bearing in a box with contacts at one end. When the box is tilted the ball rolls away from the contacts and the connection is broken. When the box is tilted to roll the other way the ball touches the contacts and completes a circuit. Markings, or pin configurations, show which way the sensor should be oriented. Tilt sensors are sensitive to small movements of around 5 to 10 degrees when
oriented with the ball just touching the contacts. If you position the sensor so that the ball bearing is directly above (or below) the contacts, the LED state will only change if it is turned right over. This can be used to tell if something is upright or upside down. To determine if something is being shaken, you need to check

Reading More Than Six Analog Inputs

ARDUINO-Reading  Analog Inputs
               A standard Arduino board has six analog inputs (the Mega has 16) and there may not be enough
analog inputs available for your application. Perhaps you want to adjust eight parameters in your application by turning knobs on eight potentiometers.Use a multiplexer chip to select and connect multiple voltage sources to one analog input. By sequentially selecting from multiple sources, you can read each source in turn. This recipe uses the popular 4051 chip connected to Arduino. Your analog inputs get connected to the 4051 pins marked Ch 0 to Ch 7. Make sure the voltage on the channel input pins is never higher than 5 volts:

Reading a Keypad

ARDUINO-Reading a Keypad:
      Matrix keypads typically consist of Normally Open switches that connect a row with a column when pressed. Each of the four rows is connected to an input pin and each column is connected to an output pin. The setup function sets the pin modes and enables pull-up resistors on the input pins (see the pull-up recipes in the beginning of this chapter). The getkey function sequentially sets the pin for each column LOW and then checks to see if any of the row pins are LOW. Because pull-up resistors are used, the rows will be high (pulled up) unless a switch is closed (closing a switch produces a LOW signal on the input pin). If they are LOW, this indicates that the switch for that row and column is closed. A delay is used to ensure that the