Cintillo Institucional

wiki comunidad

Proyecto Hardware Libre Cenditel

Página Cenditel

wiki Cenditel

Plataforma de Desarrollo Colaborativo

Curso Sensibilización Hardware Libre (Unidad 002)

logohl.png logohl.png logohl.png

002/04 Actividad 004

En esta actividad, se plantea el uso de la librería de arduino LCD, en una primera aproximación se plantea el uso de pantalla LCD, donde se visualice un contador que se reinicie cada 100 iteraciones, para luego realizar otras actividades,

/*
Carlos Soto
check 3/05/11
Manejo LCD 
*/


//Este programa maneja la LCD con un arduino mega 

#include <Wire.h>

int dd=50;
#define expander B0100000  // Direccion del expansor alpha-num
                           // 0  1   0   0   A2  A1  A0
                           // 0  1   0   0   0   0    0
// Note that the R/W bit is not part of this address.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

//Manejo de Entradas
const int inPin01 = 4; 
const int inPin02 = 5; 
const int inPin03 = 6; 
const int inPin04 = 7; 
  //Manejo de Entradas en setup
  int inState01 = 0;
  int inState02 = 0;
  int inState03 = 0;
  int inState04 = 0;

 
                            

void setup() {
  Wire.begin();
  Serial.begin(9600);

  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("HAPA 001");
}

void loop() {

  inState01 = digitalRead(inPin01);
  inState02 = digitalRead(inPin02);
  inState03 = digitalRead(inPin03);
  inState04 = digitalRead(inPin04);


  if (inState04 == LOW) {     
    // turn LED on:    
    lcd.setCursor(5, 1);
    // print the number of seconds since reset:
    lcd.print("cuatro");
  } 
  else
      if (inState03 == LOW) {     
        // turn LED on:    
        lcd.setCursor(5, 1);
        // print the number of seconds since reset:
        lcd.print("tres");
      } 
      else
           if (inState02 == LOW) {     
           // turn LED on:    
           lcd.setCursor(5, 1);
           // print the number of seconds since reset:
           lcd.print("dos");
      } 
           else 
               if (inState01 == LOW) {     
               // turn LED on:    
               lcd.setCursor(5, 1);
               // print the number of seconds since reset:
               lcd.print("uno");
               }
               else
               {
               // turn LED on:    
               lcd.setCursor(5, 1);
               // print the number of seconds since reset:
               lcd.print("       ");
               }
   
  

  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);



}



Códido del programa -Manejo de LCD-



Circuito de Conexión -Manejo de LCD-

lcd2.png

Materiales

Manejo de arreglo de siete segmentos

hl-bcd.png

/*
 * Print "HOLA" into 7 segment array display
 *
 * (c) 2010 Alberto Medrano (alberto@cenditel.gob.ve)
 * CENDITEL Foundation
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

int potPin = 0;    // select the input pin for the potentiometer
int val = 0;

int common_0 = 12;
int common_1 = 11;
int common_2 = 10;
int common_3 = 9;
int bcd_A = 8;
int bcd_B = 7;
int bcd_C = 6;
int bcd_D = 5;
int bcd_E = 4;
int bcd_F = 3;
int bcd_G = 2;

void setup() {
  pinMode(common_0, OUTPUT);  // Declarando Salidas
  pinMode(common_1, OUTPUT);  // Declarando Salidas
  pinMode(common_2, OUTPUT);  // Declarando Salidas
  pinMode(common_3, OUTPUT);  // Declarando Salidas
  pinMode(bcd_A, OUTPUT);  // Declarando Salidas
  pinMode(bcd_B, OUTPUT);  // Declarando Salidas
  pinMode(bcd_C, OUTPUT);  // Declarando Salidas
  pinMode(bcd_D, OUTPUT);  // Declarando Salidas
  pinMode(bcd_E, OUTPUT);  // Declarando Salidas
  pinMode(bcd_F, OUTPUT);  // Declarando Salidas
  pinMode(bcd_G, OUTPUT);  // Declarando Salidas

  digitalWrite(common_0, LOW);
  digitalWrite(common_1, LOW);
  digitalWrite(common_2, LOW);
  digitalWrite(common_3, LOW);
}

void loop() {
  val = analogRead(potPin);    // read the value from potentiometer
  digitalWrite(bcd_A, LOW);    // H
  digitalWrite(bcd_B, HIGH);
  digitalWrite(bcd_C, HIGH);
  digitalWrite(bcd_D, LOW);
  digitalWrite(bcd_E, HIGH);
  digitalWrite(bcd_F, HIGH);
  digitalWrite(bcd_G, HIGH);
  digitalWrite(common_0, HIGH);
  delay(val);
  digitalWrite(common_0, LOW);

  val = analogRead(potPin);    // read the value from potentiometer
  digitalWrite(bcd_A, HIGH);  // O
  digitalWrite(bcd_B, HIGH);
  digitalWrite(bcd_C, HIGH);
  digitalWrite(bcd_D, HIGH);
  digitalWrite(bcd_E, HIGH);
  digitalWrite(bcd_F, HIGH);
  digitalWrite(bcd_G, LOW);
  digitalWrite(common_1, HIGH);
  delay(val);
  digitalWrite(common_1, LOW);

  val = analogRead(potPin);    // read the value from potentiometer
  digitalWrite(bcd_A, LOW);  // L
  digitalWrite(bcd_B, LOW);
  digitalWrite(bcd_C, LOW);
  digitalWrite(bcd_D, HIGH);
  digitalWrite(bcd_E, HIGH);
  digitalWrite(bcd_F, HIGH);
  digitalWrite(bcd_G, LOW);
  digitalWrite(common_2, HIGH);
  delay(val);
  digitalWrite(common_2, LOW);

  val = analogRead(potPin);    // read the value from potentiometer
  digitalWrite(bcd_A, HIGH);  // A
  digitalWrite(bcd_B, HIGH);
  digitalWrite(bcd_C, HIGH);
  digitalWrite(bcd_D, LOW);
  digitalWrite(bcd_E, HIGH);
  digitalWrite(bcd_F, HIGH);
  digitalWrite(bcd_G, HIGH);
  digitalWrite(common_3, HIGH);
  delay(val);
  digitalWrite(common_3, LOW);
}