FRIENDz

FAILURE IS THE SIGN OF SUCCESS!!

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

Controlling LEDs using Switches

ARDUINO-Controlling LEDs using Switches:

You want to create and use a group of values (called arrays). The arrays may be a simple list or they could have two or more dimensions. You want to know how to determine the size of the array and how to access the elements in the array.This sketch creates two arrays: an array of integers for pins connected to switches and an array of pins connected to LEDs:

Servo Motor Rotation using AVR

Servo Motor Interfacing with AVR
Servos are positioning motors with a built-in feedback circuit, and it’s this internal circuitry that makes them so simple to use. As positioning motors, they don’t spin
around and around like traditional motors. Instead, they only rotate through 180
degrees or so, and they can move to the desired position to roughly the nearest
degree on command. This makes them ideal for pulling up the landing gear on a
model airplane, or for moving robot arms.

Timers PWM Demo

AVR Timers PWM :
             You might be wondering why we’re only lighting up three LEDs using the hardware PWM, and the sad reason is that the AVR’s dedicated PWM pins are limited to two per timer, for a total of six: four pins at an 8-bit PWM depth, and two at 16 bits. So the software lights up three LEDs in a row with the PWM values you’ve typed, shifting the new value in, the current values over, and the oldest value out.
As with the rest of the timer/counter-based code demos so far, the event loop is quite sparse. It gets a value from the serial port and then shifts the values up a chain, corresponding to the output compare registers of LED1, LED2, and LED3. Note how we don’t need to use any more variables to store the “previous” values

Brute Force PWM

Brute-Force PWM:
    This code is split up into two distinct parts. The function pwmAllPins() takes care of implementing PWM. The remaining code in the event loop increases and decreases a brightness variable. Calling pwmAllPins() with the increasing and decreasing brightness makes the LEDs pulse in and out. In pwmAllPins(), we have a loop over i, which takes exactly 256 steps each time. Inside the i loop, we compare a variable brightness to i and turn on the LEDs if i is smaller. This has the effect of turning on the LEDs at the beginning of each set
of 256 and then turning them off as soon as i reaches the value brightness, so for higher values of brightness the LEDs stay on for a greater percentage of the 256 steps.

AM Radio

AM Radio Using AVR

This code section really gets to show off what timers can do, and we even get to combine a timer with interrupts. Hold on tight! In the radio code, we’ll be using Timer 0 in CTC mode as we did earlier to generate audio in the improved organ code. That is, we have the counter count up to a value that determines its frequency, and then clear the counter and start over at zero.This code section really gets to show off what timers can do, and we even get to combine a timer with interrupts. Hold on tight! In the radio code, we’ll be using Timer 0 in CTC mode as we did earlier to generate audio in the improved organ code. That is, we have the counter count up to a value that determines its frequency, and then clear the counter and start over at zero.simply turn on and off the carrier signal to modulate it, generating the audio on top.

AVR Interfacing with Capacitive Sensor

Capacitive Sensor:

The basic principle behind capacitive touch sensors is the same: timing how long it takes for a capacitor to charge or discharge. When nobody is nearby, the sensor plate itself will have some roughly fixed capacitance of its own, and it will take a given amount of time to charge and discharge at a given voltage. When you come along, your body capacitance couples with the circuit. The resulting capacitor— made up of you and the sensor—has more capacitance than the sensor’s capacitor alone, and so takes longer to charge and discharge. Measuring the change in charge time, allowing for environmental variation and more, lets you determine when the “button” is pressed.