Pare este circuito, usamos un optocoplador y un triac, para hacer encender la lámpara desde un blink de arduino.
Tuesday, November 17, 2009
Delay 5v a 110/220v
Pare este circuito, usamos un optocoplador y un triac, para hacer encender la lámpara desde un blink de arduino.
Monday, November 16, 2009
Sábado 14 de noviembre
salida digital a 110v
+ 5v --- 110v control. (circuito con optocoplador y triac)
internal timer (variables & words length)
LM35 (temperatura)
Preamplificador para audio
PWM sonido
Como algo nuevo en el código programamos una funcion "play()" y también usamos la estructura switch y case, para generar diferentes sonidos.


int sound=10;
int switcher=5;
int val=0;
int val2=0;
int into=0;
void setup(){
pinMode(sound, OUTPUT);
pinMode(switcher, INPUT);
}
void play(int val){
switch(val){
case 1:
digitalWrite(sound,HIGH);
delayMicroseconds(1700);
digitalWrite(sound,LOW);
delayMicroseconds(1700);
break;
case 2:
digitalWrite(sound,HIGH);
delayMicroseconds(1950);
digitalWrite(sound,LOW);
delayMicroseconds(1950);
break;
case 3:
digitalWrite(sound,HIGH);
delayMicroseconds(900);
digitalWrite(sound,LOW);
delayMicroseconds(900);
break;
}
}
void loop(){
val2=digitalRead(switcher);
if (val2==1){
into=1;
play(into);
}else{
into=2;
play(into);
}
}
fotocelda + dos salidas digitales
int potPin = 0; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor
int led1=7; // digital output 1
int led2=6; // digital output2
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
if(val >= 512){
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
}else{
digitalWrite(led2, HIGH);
digitalWrite(led1, LOW);
}
delay(200);
}
Entradas Analogas + comunicación serial
Usamos un potenciometro de 10k para ver el funcionamiento los puertos análogos. También el el código nos comunicamos de forma serial con nuestro PC, pudiendo observar los datos en la escala de 0 a 1023.

int potPin = 0; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
Serial.print(val);
Serial.print(" ");
delay(200);
}
Subscribe to:
Posts (Atom)
