Modifications

Aller à : navigation, rechercher

Cestpasidiot

1 687 octets ajoutés, 16 septembre 2015 à 13:26
récepteur pour capteur DHT + luxmètre : + détecteur de mouvement
</pre>
=== récepteur pour capteur DHT + luxmètre + télémètre + détecteur de mouvement ===
<pre>
#include <VirtualWire.h> // librairie radio
#define RADIO_PIN 3 // broche DATA du récepteur RF
 
// message reçu.
float tempValue = 0;
float humidityValue = 0;
int luxValue = 0;
float distanceValue = 0;
 
 
void setup() {
Serial.begin(9600);
vw_setup(2000); // Bits par seconde
vw_set_rx_pin(RADIO_PIN); // broche DATA du récepteur
vw_rx_start();
Serial.println("Virtual wire started");
}
 
void loop() {
// Get current button state.
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
String ficelle="";
if (vw_get_message(buf, &buflen)) // On test afin de savoir si un message est reçu.
{
int i;
int nombre;
//Serial.println("nouveau msg");
for (i = 0; i <= buflen; i++)
{
ficelle+=char(buf[i]); // msg lettre par lettre. buf[4] == 5ème lettre envoyée
}
ficelle[buflen] = '\0';
Serial.print("ficelle : ");
Serial.println(ficelle);
tempValue=(ficelle.substring(0,2).toInt());
humidityValue=(ficelle.substring(2,4).toInt());
luxValue=(ficelle.substring(4,6).toInt());
distanceValue=(ficelle.substring(6,8).toInt());
motionValue=(ficelle.substring(8,9).toInt());
 
//Serial.print(luxValue);
//Serial.println(" lux");
}
}
 
//============== FIN DU LOOP ==============================
 
//============== emplacements de vos fonctions ==============================
 
 
//============== fonctions à ne pas modifier ==============================
 
 
 
</pre>
=== récepteur pour capteur DHT + luxmètre ===
<pre>
Emailconfirmed
471
modifications

Menu de navigation