Modifications

Sauter à la navigation Sauter à la recherche
82 octets ajoutés ,  29 octobre 2018 à 22:08
Ligne 297 : Ligne 297 :  
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
The {{fname|init_radio_module()}} function is called from the {{fname|setup()}}.
 +
 +
This function does all the stuff to initialize the RFM69HCW modules. Set the transmission power, the frequency and the '''encryption key'''.
    
<syntaxhighlight lang="c">  
 
<syntaxhighlight lang="c">  
Ligne 339 : Ligne 343 :  
   Serial.println(" MHz");
 
   Serial.println(" MHz");
 
}
 
}
 +
</syntaxhighlight>
    +
<syntaxhighlight lang="c">
 
void send_header() {
 
void send_header() {
 
   // Send header about the data  Serial.println(F("***START***"));
 
   // Send header about the data  Serial.println(F("***START***"));
Ligne 351 : Ligne 357 :  
    
 
    
 
}
 
}
 +
</syntaxhighlight>
    +
<syntaxhighlight lang="c">
 
void Blink(byte PIN, byte DELAY_MS, byte loops) {
 
void Blink(byte PIN, byte DELAY_MS, byte loops) {
 
   for (byte i=0; i<loops; i++)  {
 
   for (byte i=0; i<loops; i++)  {
Ligne 362 : Ligne 370 :  
   delay( 3* DELAY_MS );
 
   delay( 3* DELAY_MS );
 
}
 
}
 +
</syntaxhighlight>
 +
 +
This function returns the voltage for the analog Pin.
 +
 +
It converts a digital value between 0 & 1024 (from ADC) to voltage between 0 & 3.3 volts.
   −
/*
+
<syntaxhighlight lang="c">
* getVoltage() - return the voltage of an analog pin
  −
*/
   
float getVoltage(int pin){
 
float getVoltage(int pin){
   // AS the sketch does not call the analogReadResolution()
+
   // each unit equal 3.3 / 1024 = 3.2 millivolts
  //    function to change the analog reading resolution
  −
  // THEN Arduino use the defaut 12 bits resolution!
  −
  // Under 12 bits resolution, the analogRead() returns
  −
  //    a value between 0 & 1024.
  −
  //
  −
  // Convert digital value between 0 & 1024 to
  −
  //    voltage between 0 & 3.3 volts.
  −
  //    (each unit equal 3.3 / 1024 = 3.2 millivolts)
   
   return (analogRead(pin) * .0032);
 
   return (analogRead(pin) * .0032);
 
}
 
}
29 837

modifications

Menu de navigation