Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
eviallet authored Jun 5, 2019
1 parent d4dfce1 commit 5c4003e
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,68 @@ It is based on the official C API, but handles registers communications to provi

The docs are generated with Doxygen. Each line of code is documented and examples are provided for each class.

* Blink a LED

```cpp
#include "MyRIO.h"
using namespace myRIO;
int main() {
if(!myRIO_init()) {std::cout << "Error initializing myRIO"; return -1;}

bool status = HIGH;

while(1) {
status=!status
DIO::writeLed(LED1, status);
Time::wait_ms(500);
}
}
```

* Output a PWM signal

```cpp
#include "MyRIO.h"
using namespace myRIO;
using namespace std;
int main() {
if(!myRIO_init()) {cout << "Error initializing myRIO"; return -1;}
// Output a 10kHz, 3.3V PWM signal with a duty cycle of 25% for 10 seconds
PWM channelC0(PWMC0, 10e3, 25);
Time::wait_s(10);
}
```

* Generate a sine with AIO class (Analog Input Output)

```cpp
#include "MyRIO.h"
using namespace myRIO;
using namespace std;
int main() {
if(!myRIO_init()) {cout << "Error initializing myRIO"; return -1;}
double fq = 100;
double vpp = 4;
double outputFq = 100e3;
Time timer = Time::stopwatch();
timer.reset();
while(1) {
AIO::writePin(CO0, (vpp/2)*sin(2*3.141592653*fq*timer.elapsed_ns()*1e-9));
// we cannot measure more than 2 seconds ; reset it before it's too late
if(timer.elapsed_ns() >= 1e9L)
timer.reset();
// convert the frequency to time, then the time to µs
Time::wait_us(1e6/outputFq);
}
return 0;
}
```

*




* LEDs example

[![Youtube video 2](https://img.youtube.com/vi/AXE74Ngltvw/0.jpg)](https://youtu.be/AXE74Ngltvw)
Expand Down

0 comments on commit 5c4003e

Please sign in to comment.