viernes, 11 de julio de 2014

interfaz espacial con arduino

hoy tomaremos otro pequeño proyecto que nos asegura los conocimientos basicos en entradas y salidas con arduino en los pines digitales basicos con una tematica espacial muy interesante

materiales:
arduino uno con IDE (compilador de codigos de arduino) instalado en su computadora
3 led (color a preferencia del usuario)
protoboard
3 resistencias de 220 ohms
pulsador normalmente abierto o microswitch
cables jumper e diferentes colores y tamaños



el diagrama es el siguiente:


y el codigo de muestra a continuacion:




 Parts required:
 1 green LED
 2 red LEDs
 pushbutton
 10 kilohm resistor
 3 220 ohm resistors


*/

// Create a global variable to hold the
// state of the switch. This variable is persistent
// throughout the program. Whenever you refer to
// switchState, you’re talking about the number it holds
int switchstate = 0;

void setup() {
  // declare the LED pins as outputs
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

  // declare the switch pin as an input
  pinMode(2, INPUT);
}

void loop() {

  // read the value of the switch
  // digitalRead() checks to see if there is voltage
  // on the pin or not
  switchstate = digitalRead(2);

  // if the button is not pressed
  // blink the red LEDs
  if (switchstate == LOW) {
    digitalWrite(3, HIGH); // turn the green LED on pin 3 on
    digitalWrite(4, LOW);  // turn the red LED on pin 4 off
    digitalWrite(5, LOW);  // turn the red LED on pin 5 off
  }
  // this else is part of the above if() statement.
  // if the switch is not LOW (the button is pressed)
  // the code below will run
  else {
    digitalWrite(3, LOW);  // turn the green LED on pin 3 off
    digitalWrite(4, LOW);  // turn the red LED on pin 4 off
    digitalWrite(5, HIGH); // turn the red LED on pin 5 on
    // wait for a quarter second before changing the light
    delay(250);
    digitalWrite(4, HIGH); // turn the red LED on pin 4 on
    digitalWrite(5, LOW);  // turn the red LED on pin 5 off
    // wait for a quarter second before changing the light
    delay(250);
  }
}



termometro con sensor de temperatura TMP36

conociendo las entradas y salidas de las tarjetas arduino ahora tomaremos el tema de las entradas analogicas y sus posibles funciones el dia de hoy haremos un termometro simple con un sensor economico y muy preciso:

materiales:
tarjeta arduino uno con software ide
3 leds de colores 
resistores de 220 ohms
cables jumper
protoboard
sensor de temperatura TMP36

el diagrama de armado se presenta a continuacion:

el codigo que utilizaremos es el siguiente:
/*


 Parts required:
 1 TMP36 temperature sensor
 3 red LEDs
 3 220 ohm resistors


 */

// named constant for the pin the sensor is connected to
const int sensorPin = A0;
// room temperature in Celcius
const float baselineTemp = 20.0;

void setup() {
  // open a serial connection to display values
  Serial.begin(9600);
  // set the LED pins as outputs
  // the for() loop saves some extra coding
  for (int pinNumber = 2; pinNumber < 5; pinNumber++) {
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop() {
  // read the value on AnalogIn pin 0
  // and store it in a variable
  int sensorVal = analogRead(sensorPin);

  // send the 10-bit sensor value out the serial port
  Serial.print("sensor Value: ");
  Serial.print(sensorVal);

  // convert the ADC reading to voltage
  float voltage = (sensorVal / 1024.0) * 5.0;

  // Send the voltage level out the Serial port
  Serial.print(", Volts: ");
  Serial.print(voltage);

  // convert the voltage to temperature in degrees C
  // the sensor changes 10 mV per degree
  // the datasheet says there's a 500 mV offset
  // ((volatge - 500mV) times 100)
  Serial.print(", degrees C: ");
  float temperature = (voltage - .5) * 100;
  Serial.println(temperature);

  // if the current temperature is lower than the baseline
  // turn off all LEDs
  if (temperature < baselineTemp) {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  } // if the temperature rises 2-4 degrees, turn an LED on
  else if (temperature >= baselineTemp + 2 && temperature < baselineTemp + 4) {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  } // if the temperature rises 4-6 degrees, turn a second LED on
  else if (temperature >= baselineTemp + 4 && temperature < baselineTemp + 6) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  } // if the temperature rises more than 6 degrees, turn all LEDs on
  else if (temperature >= baselineTemp + 6) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
  delay(1);
}

NOTA: los valores de temperatura los puede ajustar el usuario a sus necesidades incluso se puede alargar la cantidad de indicadores led copiando y pegando el codigo en su parte de indicadores de salida

NOTA 2: me gustaria conocer su opinion sobre el blog y en que idiomas les gustaria verlo estoy preparandoles un canal de youtube con estos y otros proyectos

domingo, 25 de mayo de 2014

lampara con arduino(lampara de noche)

el dia de hoy les explicare como hacer una lampara de noche asumiendo que leyeron mi post anterios y ya identifican las partes de la tarjeta arduino para hacer esta lampara se requiere lo siguiente:

-tarjeta arduino uno
-un led blanco super brillante
-resistencia de 220 ohms
-cables jumper
-mini protoboard
-microswitch (push button)

ahora vamos con el diagrama:
y aqui esta el codigo:
int estado = 0; //guarda estado de boton
int salida = 0;
int estadoAnterior = 0;   //guarda estado de boton
void setup()   {
  pinMode(4,INPUT); //boton entrada
  pinMode(5,OUTPUT); //led salida
}



void loop() {
  estado = digitalRead(4); //leer estado de boton
  if((estado == HIGH) && (estadoAnterior == LOW ))   {
    salida = 1 - salida;
    delay(20);
  }
  estadoAnterior = estado;
  
  if(salida  == 1){      //si estado es alto
    digitalWrite(5,HIGH);  //led encendido 
  }
  else {
    
    digitalWrite(5 ,LOW);   //apagamos led
  }
}

sábado, 24 de mayo de 2014

Blinking with arduino

blinking proyect with arduino:proyecto de parpadeo con arduino
by: rmt tech

que es arduino?es una plataforma de software y hardware abierto para el publico en general con un sistema basado en el lenguaje processing y este hardware es facil de utilizar de programar y todo esto a un costo asequible

-para hacer que un led parpadee con una tarjeta arduino y podamos programarla como un timer se necesitan los siguientes materiales:

-tarjeta arduino uno,mega,duemilanove u otras similares (en este caso utilizaremos arduino UNO)
-leds de cualquier color a preferencia personal
-resistores 220 ohms
-cables jumper
-protoboard

lo primero que necesitamos es identificar la distribucion de los pines en nuestra tarjeta
identificados los pines utilizaremos el pin #13 que esta cerca de una conexion a tierra(GND) 
en nuestro protoboard montaremos el siguiente diagrama:
hecho esto vamos a escribir el codigo, para programar la tarjeta arduino necesitamos la plataforma de desarrollo esta se puede descargar gratis en www.arduino.cc/en/Main/Software 

ya descargado el software abrimos nuestra pagina principal del programa y escribimos el siguiente codigo:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}


y listo tenemos un timer o led de parpadeo para utilizarse en otros proyectos
el valor de 1000=1 segundo estan en milisegundos
si se requiere de algun ajuste de parpadeo se varia solo el tiempo de las funciones delay