Statistics
| Branch: | Revision:

brix5 / firmware / demo / FeatherBase-DRV2605-BasicEffects / FeatherBase-DRV2605-BasicEffects.ino @ f175b4b0

History | View | Annotate | Download (952 Bytes)

1
#include <Wire.h>
2
#include "Adafruit_DRV2605.h"
3

    
4
// Play all effects of Immersion Library on DRV2605(L)
5
// based on basic example of Adafruit DRV2605 library
6

    
7
// Comment following line for ERM support
8
#define USE_LRA 1
9

    
10
Adafruit_DRV2605 drv;
11

    
12
void setup() {
13
  Serial.begin(9600);
14
  Serial.println("DRV test");
15

    
16
  // Enable DRV2605
17
  pinMode(A1, OUTPUT);
18
  digitalWrite(A1, HIGH);
19
  
20
  drv.begin();
21
#ifdef USE_LRA
22
  drv.selectLibrary(6);
23
  drv.useLRA();
24
#elif
25
  drv.selectLibrary(1);
26
#endif
27

    
28
  // I2C trigger by sending 'go' command 
29
  // default, internal trigger when sending GO command
30
  drv.setMode(DRV2605_MODE_INTTRIG); 
31
}
32

    
33
uint8_t effect = 1;
34

    
35
void loop() {
36
  Serial.print("Effect #"); Serial.println(effect);
37

    
38
  // set the effect to play
39
  drv.setWaveform(0, effect);  // play effect 
40
  drv.setWaveform(1, 0);       // end waveform
41

    
42
  // play the effect!
43
  drv.go();
44

    
45
  // wait a bit
46
  delay(500);
47

    
48
  effect++;
49
  if (effect > 117) effect = 1;
50
}