15
Equipo: #1 LED Bar Graph The bar graph - a series of LEDs in a line, such as you see on an audio display - is a common hardware display for analog sensors. It's made up of a series of LEDs in a row, an analog input like a potentiometer, and a little code in between. You can buy multi-LED bar graph displays fairly cheaply, like this one . This tutorial demonstrates how to control a series of LEDs in a row, but can be applied to any series of digital outputs. This tutorial borrows from the For Loop and Arrays tutorial as well as the Analog Input tutorial. The sketch works like this: first you read the input. You map the input value to the output range, in this case ten LEDs. Then you set up a for loop to iterate over the outputs. If the output's number in the series is lower than the mapped input range, you turn it on. If not, you turn it off. Hardware Required Arduino Board (1) LED bar graph display or 10 LEDs (10) 220 ohm resistors hook-up wire breadboard Circuit click the image to enlarge

Practicas Unidad 4

  • Upload
    cris-ro

  • View
    51

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Practicas Unidad 4

Equipo: #1

LED Bar Graph

The bar graph - a series of LEDs in a line, such as you see on an audio display - is a common hardware display for analog sensors. It's made up of a series of LEDs in a row, an analog input like a potentiometer, and a little code in between. You can buy multi-LED bar graph displays fairly cheaply, like this one. This tutorial demonstrates how to control a series of LEDs in a row, but can be applied to any series of digital outputs.

This tutorial borrows from the For Loop and Arrays tutorial as well as the Analog Input tutorial.

The sketch works like this: first you read the input. You map the input value to the output range, in this case ten LEDs. Then you set up a for loop to iterate over the outputs. If the output's number in the series is lower than the mapped input range, you turn it on. If not, you turn it off.

Hardware Required

Arduino Board (1) LED bar graph display or 10 LEDs (10) 220 ohm resistors hook-up wire breadboard

Circuit

click the image to enlarge

Page 2: Practicas Unidad 4

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic:

click the image to enlarge

Page 4: Practicas Unidad 4

Equipo: “2”

Row-columm Scanning to control an 8x8 LED Matrix

LED displays are often packaged as matrixes of LEDs arranged in rows of common anodes and columns of common cathodes, or the reverse. Here's a typical example, and its schematic:

Page 5: Practicas Unidad 4

These can be very useful displays. To control a matrix, you connect both its rows and columns to your microcontroller. The columns are connected to the LEDs anodes (see Figure 1), so a column needs to be high for any of the LEDs in that column to turn on. The rows are connected to the LEDs cathodes, so the row needs to be low for an individual LED to turn on. If the row and the column are both high or both low, no voltage flows through the LED and it doesn’t turn on.

To control an individual LED, you set its column high and its row low. To control multiple LEDs in a row, you set the rows high, then take the column high, then set the lows row or high as appropriate; a low row will turn the corresponding LED on, and a high row will turn it off.

Although there are pre-made LED matrices, you can also make your own matrix from 64 LEDs, using the schematic as shown above.

It doesn’t matter which pins of the microcontroller you connect the rows and columns to, because you can assign things in software. Connected the pins in a way that makes wiring easiest. A typical layout is shown below.

Here's a matrix of the pin connections, based on the diagram above:

Matrix pin no. Row Column Arduino pin number

1 5 - 13

2 7 - 12

3 - 2 11

4 - 3 10

5 8 - 16 (analog pin 2)

6 - 5 17 (analog pin 3)

7 6 - 18 (analog pin 4)

8 3 - 19 (analog pin 5)

9 1 - 2

10 - 4 3

11 - 6 4

12 4 - 5

13 - 1 6

14 2 - 7

15 - 7 8

16 - 8 9

Hardware Required

Page 6: Practicas Unidad 4

Arduino Board (1) 8 x 8 LED Matrix (2) potentiometers hook-up wire breadboard

Circuit

The 16 pins of the matrix are hooked up to 16 pins of the Arduino. Four of the analog pins are used as digital inputs 16 through 19. The order of the pins is assigned in two arrays in the code.

Two potentiometers, connected to analog pins 0 and 1, control the movement of a lit LED in the matrix.

click the image to enlarge

Page 7: Practicas Unidad 4

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic:

click the image to enlarge.

Page 8: Practicas Unidad 4

Equipo: #3

Arrays

This variation on the For Loop example shows how to use an array. An array is a variable with multiple parts. If you think of a variable as a cup that holds values, you might think of an array as an ice cube tray. It's like a series of linked cups, all of which can hold the same maximum value.

The For Loop example shows you how to light up a series of LEDs attached to pins 2 through 7 of the Arduino, with certain limitations (the pins have to be numbered contiguously, and the LEDs have to be turned on in sequence).

This example shows you how you can turn on a sequence of pins whose numbers are neither contiguous nor necessarily sequential. To do this is, you can put the pin numbers in an array and then use for loops to iterate over the array.

This example makes use of 6 LEDs connected to the pins 2 - 7 on the board using 220 Ohm resistors, just like in the For Loop. However, here the order of the LEDs is determined by their order in the array, not by their physical order.

Page 9: Practicas Unidad 4

This technique of putting the pins in an array is very handy. You don't have to have the pins sequential to one another, or even in the same order. You can rearrange them however you want.

Hardware Required

Arduino Board (6) 220 ohm resistors (6) LEDs hook-up wire breadboard

Circuit

Connect six LEDS, with 220 ohm resistors in series, to digital pins 2-7 on your Arduino.

click the image to enlarge

Page 10: Practicas Unidad 4

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic:

click the image to enlarge

Page 11: Practicas Unidad 4

Equipo: #4

Pitch follower using the tone() function

This example shows how to use the tone() command to generate a pitch that follows the values of an analog input

Hardware Required

8-ohm speaker 1 photocell 4.7K ohm resistor 100 ohm resistor breadboard hook up wire

Circuit

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Connect one terminal of your speaker to digital pin 8 through a 100 ohm resistor, and its other terminal to ground. Power your photoresistor with 5V, and connect it to analog 0 with the addition of a 4.7K resistor to ground.

Page 13: Practicas Unidad 4

Archivo :contador.pde

2 digit 7 segment 0-99 counting with arduino

2 digit 7 segment 0-99 counting with arduino vary speed of counting from potentiometer

Page 14: Practicas Unidad 4

2 digit 7 segment 0-99 counting with arduino vary speed of counting from potentiometer.

470 ohm resistor for all 7 segment pin. 1 potentiometer connect to analog device.