PRACTICA MATRIZ LED
///////////////// Definimos las letras en Hexadecimal//////////////////////////////////////////////////////////////////
// SE TIENEN DE AGREGAR MAS LETRAS DEACUERDO A TU NECESIDAD
byte R[] = { 0x78, 0x44, 0x44, 0x78, 0x70, 0x58, 0x4C, 0x46 };
byte O[] = { 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C };
byte B[]= { 0x78, 0x44, 0x44, 0x78, 0x70, 0x44, 0x44, 0x78 };
byte A[] = { 0x7E, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42 };
byte I[] = { 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,0x3C };
byte W[] = { 0x00, 0x6C, 0x92, 0x82, 0x44, 0x28, 0x10, 0x00 }; //// Se uso la Letra W para dibujar un corazón
byte Z[]= { 0x00, 0x6C, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00 };
byte N[]= { 0x42, 0x62, 0x72, 0x5A, 0x4E, 0x46, 0x42, 0x42 };
byte T[] = { 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 };
byte C[] = { 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C };
byte dot[]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06 };
byte sp[]= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{ for (int j=2; j<19; j++) ///Definimos todos los pines del arduino como salida
pinMode(j, OUTPUT);
Serial.begin(9600);
}
void SetChar(char p)
{
Clear();
for (int fil = 0; fil <8 ; fil++)
{
digitalWrite( fil + 10 , LOW) ; // Activamos la fila para el barrido
//byte F = N[fil] ;
byte F = Selecciona( p, fil);
for (int col =7; col >= 0 ; col--)
{
digitalWrite(8-col, LOW); //Bajamos la columna
bool b = GetBit(F, col) ;
if (b)
digitalWrite( 9 - col ,HIGH); //Levantamos la columna, con su pin
else
digitalWrite( 9 - col ,LOW); // Si 0, apagamos
} // Solo si b es 1
digitalWrite( fil + 10 , HIGH) ; // Apagamos fila antes de salir
}
}
bool GetBit( byte N, int pos)
{ // pos = 7 6 5 4 3 2 1 0
int b = N >> pos ; // Shift bits
b = b & 1 ; // coger solo el ultimo bit
return b ;
}
void Clear()
{
for (int j=2; j<10; j++) // Valores de los pines de columna
digitalWrite(j, LOW); // Todos apagados
for (int k= 10 ; k<18 ; k++)
digitalWrite(k, HIGH); // Todas las filas cortadas
}
///////////////////////////////////////////////////////////////// POR CADA LETRA AGREGA AL INICIO DEL PROGRAMA, SE TIENE QUE AGREGAR "if (c == 'NUEVA LETRA') return(NUEVA LETRA[fil]) ;"
byte Selecciona( char c, byte fil)
{
if (c == 'R') return(R[fil]) ;
if (c == 'O') return( O[fil]);
if (c == 'B') return( B[fil]);
if (c == 'O') return( O[fil]);
if (c == 'T') return( T[fil]);
if (c == 'R') return( R[fil]);
if (c == 'O') return( O[fil]);
if (c == 'N') return( N[fil]);
if (c == 'I') return( I[fil]);
if (c == 'C') return( C[fil]);
if (c == 'A') return( A[fil]);
if (c == 'W') return( W[fil]);
if (c == 'Z') return( Z[fil]);
if (c == '.') return( dot[fil]);
if (c == ' ') return( sp[fil]);
}
////////////////////////////////////////////////////////////////////
void loop()
{
String s = "ROBOTRONICA W " ; /////////////////////////////AQUI SE ESCRIBE EL TEXTO A MOSTRAR
int l = s.length(); // Calcula la longitus de s
for ( int n = 0; n< l; n++ )
{
long t = millis();
char c = s[n];
while ( millis()< t+ 500) ///Se difine el tiempo de cambio de letra.
SetChar(c);
}
}
PRACTICA Bluetooth
// C++ code
//
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(LED_BUILTIN, LOW);
delay(1000); // Wait for 1000 millisecond(s)
PRACTICA CONTADOR (LCD)
//7 Segmentos de display
int a = 12;
int b = 8;
int c = 4;
int d = 6;
int e = 7;
int f = 11;
int g = 3;
// digitoos de Display
int dg1 = 2;
int dg2 = 9;
int dg3 = 10;
int dg4 = 13;
//Punto
int dp=5;
//Velocidad
int vel=1;
//Unidades,decenas, centenas y millares
int mil,cien,dec,uni;
byte segmentos[7] = { a,b,c,d,e,f,g };
byte orden_digitos[4] = { dg1,dg2,dg3,dg4 };
byte digitos[4][4] = { { 0,0,0,1 },
{ 0,0,1,0 },
{ 0,1,0,0 },
{ 1,0,0,0 }
};
byte siete_segmentos_digitos[10][7] = { { 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
{ 1,1,1,1,0,0,1 }, // = 3
{ 0,1,1,0,0,1,1 }, // = 4
{ 1,0,1,1,0,1,1 }, // = 5
{ 1,0,1,1,1,1,1 }, // = 6
{ 1,1,1,0,0,0,0 }, // = 7
{ 1,1,1,1,1,1,1 }, // = 8
{ 1,1,1,0,0,1,1 } // = 9
};
void EscribeDigito(byte digito, byte numero) {
int secuencia = 0;
//Activa número
ActivarDigito(digito);
//digitalWrite(dp,1);//Punto
//Escribe Numero
for (byte i = 0; i < 7; i++){
digitalWrite(segmentos[secuencia], siete_segmentos_digitos[numero][i]);
++secuencia;
}
}
void ActivarDigito(int x){
digitalWrite(dg1, HIGH);
digitalWrite(dg2, HIGH);
digitalWrite(dg3, HIGH);
digitalWrite(dg4, HIGH);
switch(x){
case 1:
digitalWrite(dg1, LOW);
break;
case 2:
digitalWrite(dg2, LOW);
break;
case 3:
digitalWrite(dg3, LOW);
break;
default:
digitalWrite(dg4, LOW);
break;
}
}
void setup(){
int i;
//Inicializar Pines
for(i=2; i <= 13;i++)
pinMode(i,OUTPUT);
}
void loop(){
start();
}
//funcion 0 a 9999
void start(){
for(mil=0;mil<=9;mil++){
for(cien=0;cien<=9;cien++){
for(dec=0;dec<=9;dec++){
for(uni=0;uni<=9;uni++){
EscribeDigito(1, uni);
delay(vel);
EscribeDigito(2, dec);
delay(vel);
EscribeDigito(3, cien);
delay(vel);
EscribeDigito(4, mil);
delay(vel);
}
}
}
}
}
PRACTICA MOTOR
/*Declaramos la correspondencia entre pines del ARDUINO y el driver
ULN2003.
*/
int motorPin1 = 8; //pin8----1N4
int motorPin2 = 9; //pin8----1N3
int motorPin3 = 10; //pin8----1N2
int motorPin4 = 11; //pin8----1N1
//Definimos la función que provocará el giro antihorario
/* El parámetro de entrada "delayTime" definirá la velocidad de giro
*/
void gira_antihorario(int delayTime)
{
digitalWrite(motorPin1, HIGH); // Los pines se activan en secuencia
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
//Definimos la función que provocará el giro horario
void gira_horario(int delayTime)
{
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, HIGH); // Los pines se activan en secuencia
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
}
void setup() {
pinMode(motorPin1, OUTPUT); // Configuración de los PINes como salida digital
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void loop()
//gira media vuelta en sentido antihorario rápido
{
for (int i=0; i <= 265; i++){
gira_antihorario(2);
}
delay(2000);//espera 2 segundos
//gira media vuelta en sentido horario lento
for (int i=0; i <= 265; i++){
gira_horario(18);
}
delay(2000);//espera 2 segundos
}
PRACTICA WIFI
///////////////// Definimos las letras en Hexadecimal//////////////////////////////////////////////////////////////////
// SE TIENEN DE AGREGAR MAS LETRAS DEACUERDO A TU NECESIDAD
byte R[] = { 0x78, 0x44, 0x44, 0x78, 0x70, 0x58, 0x4C, 0x46 };
byte O[] = { 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C };
byte B[]= { 0x78, 0x44, 0x44, 0x78, 0x70, 0x44, 0x44, 0x78 };
byte A[] = { 0x7E, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42 };
byte I[] = { 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,0x3C };
byte W[] = { 0x00, 0x6C, 0x92, 0x82, 0x44, 0x28, 0x10, 0x00 }; //// Se uso la Letra W para dibujar un corazón
byte Z[]= { 0x00, 0x6C, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00 };
byte N[]= { 0x42, 0x62, 0x72, 0x5A, 0x4E, 0x46, 0x42, 0x42 };
byte T[] = { 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 };
byte C[] = { 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C };
byte dot[]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06 };
byte sp[]= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{ for (int j=2; j<19; j++) ///Definimos todos los pines del arduino como salida
pinMode(j, OUTPUT);
Serial.begin(9600);
}
void SetChar(char p)
{
Clear();
for (int fil = 0; fil <8 ; fil++)
{
digitalWrite( fil + 10 , LOW) ; // Activamos la fila para el barrido
//byte F = N[fil] ;
byte F = Selecciona( p, fil);
for (int col =7; col >= 0 ; col--)
{
digitalWrite(8-col, LOW); //Bajamos la columna
bool b = GetBit(F, col) ;
if (b)
digitalWrite( 9 - col ,HIGH); //Levantamos la columna, con su pin
else
digitalWrite( 9 - col ,LOW); // Si 0, apagamos
} // Solo si b es 1
digitalWrite( fil + 10 , HIGH) ; // Apagamos fila antes de salir
}
}
bool GetBit( byte N, int pos)
{ // pos = 7 6 5 4 3 2 1 0
int b = N >> pos ; // Shift bits
b = b & 1 ; // coger solo el ultimo bit
return b ;
}
void Clear()
{
for (int j=2; j<10; j++) // Valores de los pines de columna
digitalWrite(j, LOW); // Todos apagados
for (int k= 10 ; k<18 ; k++)
digitalWrite(k, HIGH); // Todas las filas cortadas
}
///////////////////////////////////////////////////////////////// POR CADA LETRA AGREGA AL INICIO DEL PROGRAMA, SE TIENE QUE AGREGAR "if (c == 'NUEVA LETRA') return(NUEVA LETRA[fil]) ;"
byte Selecciona( char c, byte fil)
{
if (c == 'R') return(R[fil]) ;
if (c == 'O') return( O[fil]);
if (c == 'B') return( B[fil]);
if (c == 'O') return( O[fil]);
if (c == 'T') return( T[fil]);
if (c == 'R') return( R[fil]);
if (c == 'O') return( O[fil]);
if (c == 'N') return( N[fil]);
if (c == 'I') return( I[fil]);
if (c == 'C') return( C[fil]);
if (c == 'A') return( A[fil]);
if (c == 'W') return( W[fil]);
if (c == 'Z') return( Z[fil]);
if (c == '.') return( dot[fil]);
if (c == ' ') return( sp[fil]);
}
////////////////////////////////////////////////////////////////////
void loop()
{
String s = "ROBOTRONICA W " ; /////////////////////////////AQUI SE ESCRIBE EL TEXTO A MOSTRAR
int l = s.length(); // Calcula la longitus de s
for ( int n = 0; n< l; n++ )
{
long t = millis();
char c = s[n];
while ( millis()< t+ 500) ///Se difine el tiempo de cambio de letra.
SetChar(c);
}
}
Comentarios
Publicar un comentario