lunes, 11 de enero de 2016

S.O.S.

¿EN QUÉ CONSISTE?

Haremos la señal de S.O.S con un led.

¿QUÉ NECESITAREMOS?


  • 1 LED.
  • 1 RESISTENCIA DE 220Ω.


  • ARDUINO.
  • PLACA PROTOBOARD.


  • CABLES DE CONEXIÓN.

PROGRAMA:



byte ledPin = 12;

void setup()
{
  pinMode(ledPin,OUTPUT);
}

void loop()
{
 
digitalWrite(ledPin, HIGH);
// S (...) primer punto
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
digitalWrite(ledPin, HIGH);
// segundo punto
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
digitalWrite(ledPin, HIGH);
// tercer punto
delay(200);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
// 0 (— ) primera raya
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
// segunda raya
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
// tercera raya
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin, HIGH);
// S (...) primer punto
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
digitalWrite(ledPin, HIGH);
// Segundo punto
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
digitalWrite(ledPin, HIGH);
// tercer punto
delay(200);
digitalWrite(ledPin, LOW);
delay(1000);
// Espere 1 segundo antes de que empecemos de nuevo
}



CONEXIÓN:

Conectaremos el ánodo del led al pin 12 y el cátodo ira conectado a gnd a través de una resistencia de 220Ω.








lunes, 23 de noviembre de 2015

COCHE FANTÁSTICO.

¿EN QUÉ CONSISTE?

Imitaremos el coche fantástico con una secuencia de 6 leds.

¿QUÉ NECESITAREMOS?


  • 6 LEDS.
  • 6 RESISTENCIAS DE 220Ω.


  • ARDUINO.
  • CABLES DE CONEXIÓN. 
PROGRAMA:


int timer = 100;                

int ledPins[] = { 2, 3, 4, 5, 6, 7 };   
int pinCount = 6;             
void setup()
{  
  int thisPin;    
  for (int thisPin = 0; thisPin < pinCount; thisPin++) 
  {    
    pinMode(ledPins[thisPin], OUTPUT);     
    }
    }
    void loop() { 
        for (int thisPin = 0; thisPin < pinCount; thisPin++)
        {    
          digitalWrite(ledPins[thisPin], HIGH);      
          delay(timer);                     
          digitalWrite(ledPins[thisPin], LOW);    
          }  
          for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {   
               digitalWrite(ledPins[thisPin], HIGH);  
               delay(timer);    
               digitalWrite(ledPins[thisPin], LOW); 
               }
               }
         
CONEXIÓN:

Los ánodos de cada led irán a los pines 2, 3 , 4, 5, 6 y 7 y los cátodos irán conectados a gnd a través de una resistencia de 220Ω.











miércoles, 18 de noviembre de 2015

ESTRELLA FUGAZ.

¿EN QUÉ CONSISTE?

Haremos una secuencia de 11 leds.

¿QUÉ NECESITAREMOS?



  • 11 LEDS.
  • 11 RESISTENCIAS DE 220Ω.
  • ARDUINO.
·         CABLES DE CONEXIÓN.

PROGRAMA:

  
int pinArray [] = { 2,3,4,5,6,7,8,9,10,11,12 };   
 int controlLed = 13;           
 int waitNextLed = 100;      
 int tailLength = 4;    
 int lineSize = 11;   
 void setup()           
 {    
 int i;   
 pinMode (controlLed, OUTPUT);  
 for (i=0; i< lineSize; i++)    
 {      
 pinMode(pinArray[i], OUTPUT);  
 }    
 }  
  void loop()  
  {     
  int i;   
  int tailCounter = tailLength;    
  digitalWrite(controlLed, HIGH);     
  for (i=0; i<lineSize; i++)   
  {     
  digitalWrite(pinArray[i],HIGH); 
  delay(waitNextLed);         
  if (tailCounter == 0)       
{    
  digitalWrite(pinArray[i-tailLength],LOW);       
}      
else   
if (tailCounter > 0)       
tailCounter--;   
}    
for (i=(lineSize-tailLength); i<lineSize; i++)   
{    
  digitalWrite(pinArray[i],LOW);          
  delay(waitNextLed);                             
  }
  }  



CONEXIÓN:
  
Conectaremos los ánodos a los pin correspondientes (2, 3, 4, 5, 6, 7, 8, 9, 10, 11 y 12) y los cátodos se conectan a negativo a través de una resistencia de 220Ω. 




SECUENCIA DE TRES LEDS.

¿EN QUÉ CONSISTE?

Haremos encender los tres leds de forma continuada.

¿QUÉ NECESITAREMOS?



  • 3 LEDS.
  • 3 RESISTENCIAS DE 220Ω.
  • ARDUINO.
  • CABLES DE CONEXIÓN.
PROGRAMA:


void setup() 
{
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
}

void loop()
{
  for (int i=6; i< 9; i++)
  {
    digitalWrite(i,HIGH);
    delay(200);
    digitalWrite(i,LOW);
  }
}



CONEXIÓN:

Conectaremos los ánodos de cada led a su pin correspondiente (6, 7 y 8) y los cátodos irán conectados a través de una resistencia de 220Ω a negativo.





martes, 17 de noviembre de 2015

LED CON BOTÓN.

¿EN QUÉ CONSISTE?

Al pulsar el botón encenderemos el led.

¿QUÉ NECESITAREMOS?

  • 1 LED.

  • UN BOTÓN.



  • UNA RESISTENCIA DE 220Ω Y UNA RESISTENCIA DE 10KΩ.


  • ARDUINO.

  • CABLES DE CONEXIÓN.
PROGRAMA:

byte led = 12;     
int boton = 2;   
int estado = 0;  

void setup()
{
  pinMode(led,OUTPUT);
  pinMode(boton,INPUT);
}

void loop()
{
  estado=digitalRead(boton); 
  if(estado == HIGH) 
  {
    digitalWrite(led,LOW); 
  }
  else 
  {
    digitalWrite(led,HIGH);
  }
}


CONEXIÓN:

Conectaremos el ánodo del led al pin número 12 y el cátodo ira conectado a una resistencia de 220Ω  que ira conectado a gnd. El botón lo conectaremos una de sus patas a 5 v mediante una resistencia de 10kΩ, esta misma pata la conectaremos al pin número 2  y otra pata del botón se conectara a gnd.






BLINK.


¿EN QUÉ CONSISTE?



Este proyecto consiste en encender y apagar un led de forma intermitente.


¿QUÉ NECESITAREMOS?

  • 1 LED.


  • 1 RESISTENCIA DE 220Ω.





  • ARDUINO.

  •     CABLES DE CONEXIÓN. 
PROGRAMA:


byte led = 12;  
int t = 200;  //TIEMPO

void setup()
{
  pinMode(led,OUTPUT); //EL PIN 12 DE SALIDA
}

void loop()
{
  digitalWrite(led,HIGH);  //LED ENCENDIDO 
  delay(t);
  digitalWrite(led,LOW);   // LED APAGADO 
  delay(t);
}


CONEXIÓN:

Conectaremos el ánodo del led al pin número 12 y el cátodo a la resistencia de 220Ω que ira a gnd.








LISTA DE PROYECTOS.

1. BLINK.
2. LED CON BOTÓN.
3. SECUENCIA DE 3 LEDS.
4. ESTRELLA FUGAZ.
5. COCHE FANTÁSTICO.
6. S.O.S.
7. TRADUCTOR DE CÓDIGO MORSE.
8. POTENCIÓMETRO PARA ENCENDER 5 LEDS.
9. LUZ DE VELA.
10. SENSOR ANALÓGICO.
11. ZUMBADOR.
12. FRECUENCIA DE PARPADEO DE LED.
13. MEDIDOR DE DISTANCIA CON HC-SR04.
14. MEDIDOR DE LUZ AMBIENTE CON LDR.
15. SENSOR DE TEMPERATURA Y HUMEDAD. (DHT11).
16. SENSOR DE TEMPERATURA (TMP36).