Garage parkering sensor (6 / 6 steg)
Steg 6: RX MODULE(CODE)
RX-KOD
/*
SimpleReceive
Denna skiss visar textsträngar som tagits emot med VirtualWire
Anslut mottagaren data stift till Arduino stift 11
*/
#include
#include
byte meddelande [VW_MAX_MESSAGE_LEN]; en buffert för att lagra inkommande meddelanden
byte messageLength = VW_MAX_MESSAGE_LEN; storleken på meddelandet
LiquidCrystal lcd (7, 6, 5, 4, 3, 2);
Variablerna globales:
char cad [100].
int pos = 0;
void setup()
{
LCD.BEGIN (20, 4); LCD-konfiguration, 4 línes 20 tecken cada una.
lcd.setCursor (0, 0);
LCD.write("booting");
Delay(1000);
POS = 0;
LCD.Clear();
LCD.write ("lastning kod").
Delay(1000);
POS = 0;
LCD.Clear();
LCD.write(".");
Delay(900);
LCD.write(".");
Delay(900);
LCD.write(".");
Delay(900);
POS = 0;
LCD.Clear();
LCD.write("Instructables");
Delay(900);
Serial.BEGIN(9600);
Serial.println ("enheten är redo");
Initialisera IO och ISR
vw_setup(2000); Bitar per sekund
vw_rx_start(); Starta mottagaren
}
void loop()
{
byte buf [VW_MAX_MESSAGE_LEN];
byte buflen = VW_MAX_MESSAGE_LEN;
int i;
int k = VW_MAX_MESSAGE_LEN;
om (vw_get_message (buf, och buflen)) / / icke-blockerande
{
Serial.Print ("fick:");
för (int jag = 0; jag < buflen; i ++)
{
Serial.write(BUF[i]);
}
Serial.println();
}
om (vw_get_message (buf, och buflen))
{
IF(POS < 4)
lcd.setCursor (0, pos);
annat
{
POS = 0;
LCD.Clear();
}
LCD.write("Distance:");
för (jag = 0; jag < buflen; i ++)
{
LCD.write(BUF[i]);
POS ++;
}
LCD.write("cm"); / / CM eller INC
}
}