Update Extras.md

This commit is contained in:
HomeSpan 2020-11-27 19:53:29 -06:00 committed by GitHub
parent 4700f8705c
commit bffc0629cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 51 additions and 1 deletions

View File

@ -74,9 +74,59 @@ Since most RF/IR signals repeat the same train of pulses more than once, the dur
* *tickTime* - the duration, in **microseconds**, of a *tick*. This is an optional argument with a default of 1 microseconds if not specified. Valid range is 1-255 microseconds, or 0 for 256 microseconds
Below is a complete example that produces two different pulse trains with the signal output linked to the ESP32 devices built-in LED. The tick duration is set to a very long 100𝛍s, and pulse times of 1000-10,000 ticks are used, so that the individual pulses range from 100ms to 1s and are visible. In practice the default tick duration of 1𝛍s with pulse durations on the order of 100 ticks would be used to drive an actual RF or IR transmitter.
Below is a complete example that produces two different pulse trains with the signal output linked to the ESP32 device's built-in LED. For illustrative purposes tick duration is set to a very long 100𝛍s and pulse times range from of 1000-10,000 ticks so that the individual pulses are easily discernable on the LED.
```C++
/* HomeSpan RF Transmitter Example */
#include "HomeSpan.h" // include the HomeSpan library
#include "extras/RFControl.h" // include RF Control Library
void setup() {
Serial.begin(115200); // start the Serial interface
Serial.flush();
delay(1000); // wait for interface to flush
Serial.print("\n\nHomeSpan RF Transmitter Example\n\n");
RFControl rf(LED_BUILTIN); // create an instance of RFControl with signal output to the ESP32's Built-In LED
rf.clear(); // clear the pulse train memory buffer
rf.add(5000,5000); // create a pulse train with three 5000-tick high/low pulses
rf.add(5000,5000);
rf.add(5000,10000); // double duration of final low period
Serial.print("Starting 4 cycles of three 500 ms on pulses...");
rf.start(4,100); // start transmission of 4 cycles of the pulse train with 1 tick=100 microseconds
Serial.print("Done!\n");
delay(2000);
rf.clear();
for(int i=1000;i<10000;i+=1000)
rf.add(i,10000-i);
rf.add(10000,10000);
Serial.print("Starting 3 cycles of 100-1000 ms pulses...");
rf.start(3,100); // start transmission of 3 cycles of the pulse train with 1 tick=100 microseconds
Serial.print("Done!\n");
Serial.print("\nEnd Example");
} // end of setup()
void loop(){
} // end of loop()
```
---
[↩️](README.md) Back to the Welcome page