Paso 3: receptor
Aquí está el código para el receptor. Piezo juega muy fuerte alarma sonido.
int led = 13;
int altavoz = 10;
#define wait 1
#define tiempo 100
int freq = 0;
#include
void setup() {}
Serial.Begin(9600); Depuración solamente
vw_setup(2000);
vw_set_rx_pin(11);
vw_rx_start();
pinMode (altavoz, salida);
pinMode (led, salida);
}
void loop() {}
uint8_t buf [VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
Si (vw_get_message (buf & buflen))
{
para (int i = 0; i < buflen; i ++)
{
Si (buf [i] == 'A') {}
digitalWrite (led, alto);
digitalWrite (altavoz, HIGH);
para (freq = 500; freq < 3000; freq += 10)
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
para (freq = 3000; freq > 500; freq-= 10)
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
para (freq = 500;
Freq < 3000;
Freq += 10) / /
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
para (freq = 3000;
Freq > 500; Freq-= 10)
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
para (freq = 500;
Freq < 3000;
Freq += 10) / /
{
tono (altavoz,
frecuencia, tiempo);
Delay(Wait);
}
para (freq = 3000;
Freq > 500;
Freq-= 10)
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
para (freq = 500; freq < 3000; freq += 10)
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
para (freq = 3000;
Freq > 500; Freq-= 10)
{
tono (altavoz, frecuencia, tiempo);
Delay(Wait);
}
} Si (buf [i] == 'a')
{digitalWrite (led, baja); digitalWrite (altavoz, LOW);
}
}
}
}