Ejercicio 3: SMS
Emite con un zumbador el tono estándard de aviso de llegada de un mensaje de texto en un teléfono móvil.
| Novedades hardware | Novedades software |
| | Zumbador piezoeléctrico |
VIDEO DEL EJERCICIO 3
CÓDIGO FUENTE
Copyright (C) 2006 Juan Carlos Alonso de Mena
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;
See the GNU General Public License for more details?
int corto=100; //Declara la variable de argumento entero "corto" y la
int pausa=300; //inicializa con el valor 100
int largo=300;
int espera=1000;
int n=0;
int zumb=10; //PIN digital al que conectamos el zumbador
void setup(){
pinMode(zumb,OUTPUT);
}
void loop(){
for(n=0;n<3;n++){ //Iteración en la que la variable n comienza con el valor 0
digitalWrite(zumb, HIGH);// y va aumentando en 1 en cada ciclo hasta que toma el valor 2,
delay(corto); // con lo que las instrucciones comprendidas entre los corchetes
digitalWrite(zumb,LOW); // se repiten 3 veces
delay(corto);
}
delay(pausa); //Tiempo entre letras
for(n=0;n<2;n++){ //Aquí está la M
digitalWrite(zumb, HIGH);
delay(largo);
digitalWrite(zumb,LOW);
delay(largo);
}
delay(pausa);
for(n=0;n<3;n++){
digitalWrite(zumb, HIGH);
delay(corto);
digitalWrite(zumb,LOW);
delay(corto);
}
delay(espera); //Tiempo hasta repetir SMS
Volver?
Copyright (c) 2006 Juan Carlos Alonso de Mena
Permission is granted to copy, distribute and/or modify this document under the terms of
the GNU Free Documentation License, Version 1.2 or any later version published by the
Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no
Back-Cover Texts. A copy of the license is included in the section entitled
GNU Free Documentation License?.