Author Topic: Accelerometer Code Issue  (Read 366 times)

bailejor

  • Newbie
  • *
  • Posts: 7
    • View Profile
Accelerometer Code Issue
« on: April 28, 2017, 03:43:21 pm »
Hello,

I'm attempting to get accelerometer code from the examples of Github working, but whenever I attempt to use it I get "DataType LIS2DH12 is not defined"

I guess it's not clear to me how to make use of the accelerometer library. Here is the code I was attempting to run:

Code: [Select]
Class LISDH12_Test
    Shared accel As LIS2DH12
   
    Shared Event Boot()
        accel = New LIS2DH12
       
        'set accelerometer to cause interrupt if accelation is > 1.15Gs for longer than 2ms (any axis)
        accel.ConfigureShockInterrupt(1.15, 2.0)
    End Event
   
    Shared Event AccelerometerInt1()
        'debounce interrupt
        Thread.Sleep(100000)
        Thread.ClearHardwareEvent()
       
        'Read Int source register to clear interrupt
        If ((accel.GetINT1ActiveInterrupt() & LIS2DH12.INT_ACTIVE) = LIS2DH12.INT_ACTIVE) Then
            'interrupt generated
           
            LedRed = Not LedRed
           
        End If
       
        'restart interrupt       
        accel.SetINT1ActiveInterrupt(LIS2DH12.INT_SRC_XH | LIS2DH12.INT_SRC_YH | LIS2DH12.INT_SRC_ZH)
    End Event
End Class   

Share on Facebook Share on Twitter


mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: Accelerometer Code Issue
« Reply #1 on: May 02, 2017, 12:58:44 pm »
Hello,
Are you adding the LIS2DH12 library to your code? As an example, open up the temperature example in mcStudio. You'll see that there are two 'tabs' - one is the script and the other is the library. It looks to me that you have not added the library since you are getting the error that 'LIS2DH12 is not defined'

Hope that helps!
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB