FRIENDz

FAILURE IS THE SIGN OF SUCCESS!!

7-Segment LED Displays: Multiplexing

A matrix is created by passing pin numbers for the data, load, and clock pins. loop uses the write method to turn pixels on; the clar method turns the pixels off. write has three parameters: the first two identify the column and row (x and y) of an LED and the third  parameter (HIGH or LOW) turns the LED on or off.This Solution uses the popular MAX7221 LED driver chip to control four-digit commoncathode displays The MAX7221 provides a simpler solution  because it handles multiplexing and digit decoding in hardware.

Driving a 7-Segment LED Display

The segments to be lit for each numeral are held in the array called numeral. There isone byte per numeral where each bit in the byte represents one of seven segments .The array called segmentPins holds the pins associated with each segment. TheshowDigit function checks that the number ranges from zero to 9, and if valid, looks ateach segment bit and turns on the segment if the bit is set. Apin is set HIGH when turning on a segment on a commoncathode display, and it’s set LOW when turning on a segment on a common anode
display. The code here is for a common anode display, so it inverts the value as follows:

Controlling a Matrix of LEDs: Charlieplexing

The term Charlieplexing comes from Charlie Allen (of Microchip Technology, Inc.), who published the method. The technique is based on the fact that LEDs only turn on when connected the “right way” around (with the anode more positive than the cathode). Here is the table showing the LED number that is lit for the valid combinations of the three pins. L is LOW, H is HIGH, and i is INPUT mode. Setting a pin in INPUT mode effectively disconnects it from the circuit:

Controlling an LED Matrix Using Multiplexing

      The resistor’s value must be chosen to ensure that the maximum current through a pin does not exceed 40 mA. Because the current for up to eight LEDs can flow through each column pin, the maximum current for each LED must be one-eighth of 40 mA, or 5 mA. Each LED in a typical small red matrix has a forward voltage of around 1.8 volts. Calculating the resistor that results in 5 mA with a forward voltage of 1.8 volts
gives a value of 680 ohms. Check your data sheet to find the forward voltage of the matrix you want to use. Each column of the matrix is connected through the series resistor to a digital pin. When the column pin goes low and a row pin goes high, the corresponding LED will light. For all LEDs where the column pin is high or its row pin is low, no current will flow through the LED and it will not light. The for loop scans through each row and column and turns on sequential LEDs until all LEDs are lit. The loop starts with the first column and row and increments the row counter until all LEDs in that row are lit; it then moves to the next column, and so on, lighting another LED with each pass through the loop until all the LEDs are lit. You can control the

Detecting Rotation Using a Gyroscope

Arduino-Detecting Rotation Using a Gyroscope:
         Most low-cost gyroscopes use an analog voltage proportional to rotation rate, although some also  output using I2C. This recipe works with a gyro with an analog output proportional to rotation rate. Figure 6-16 shows an LISY300AL breakout board from SparkFun. Many low-cost gyros, such as the one used here, are 3.3V devices and must not be plugged into the 5V power pin.The Gyro OUT connection is the analog output and is connected to Arduino analog input 0. The PD connection enables the gyro to be switched into low power mode and is connected to analog pin 1 (in this sketch, it is used as a digital output pin). You can connect PD to any digital pin; the pin used here was chosen to keep the wiring neater. If you don’t need to switch the gyro into low-power mode, you can connect the PD line to Gnd.

Reading RFID Tags using Arduino

RFID Connected with Arduino
A tag consists of a start character followed by a 10-digit tag and is terminated by an end character. The sketch waits for a complete tag message to be available and displays the tag if it is valid. The tag is received as ASCII digits (see Recipe 4.4 for more on receiving ASCII digits). You may want to convert this into a number if you want to store or compare the values received. To do this, change the last few lines as follows:
if( Serial.read() == endByte) // check for the correct end character
{
tag[bytesread] = 0; // terminate the string
long tagValue = atol(tag); // convert the ASCII tag to a long integer

Measuring Temperature LM35

Arduino-Measuring Temperature using LM35:
The LM35 temperature sensor produces an analog voltage directly proportional to temperature with an output of 1 millivolt per 0.1°C (10 mV per degree). The sketch converts the analogRead values into millivolts and divides this by 10 to get degrees. The sensor accuracy is around 0.5°C, and in many cases you can use integer math instead of floating point. The following sketch turns on pin 2 when the temperature is above a threshold:
       This recipe displays the temperature in Fahrenheit and Celsius (Centigrade) using the popular LM35