Go Down

### Topic: Single Axis Accelerometer Breakout Board - ADXL193 +/-250g (Read 2602 times)previous topic - next topic

#### Anish142

##### Feb 16, 2014, 06:34 pm
I need some help with this sensor. I can't seem to find any sample code and also am not an experienced programmer. If anyone has some sample code for this sensor your help would be appreciated.

#### knut_ny

#1
##### Feb 16, 2014, 08:00 pmLast Edit: Feb 16, 2014, 08:31 pm by knut_ny Reason: 1
Read the datasheet..: It says ouput is 8mV/g
Code: [Select]
`float a;void setup(){Serial.begin(9600);}void loop() { a = (analogRead(A0)-511) * 4.8875855 ; //millivolt // 5/1023=0,0048875855 V/step a = a / 8; // 8mV/g // all calc can be done in one calculation Serial.println(a,2); // G-value // shoud be 0 when not moving // expect small values when 'shaking'}`
Ny

#### Anish142

#2
##### Feb 16, 2014, 08:16 pm
Do you have code that I could try to use?

#### knut_ny

#3
##### Feb 16, 2014, 08:32 pm
Read datasheet to find if ST shoud be wired hi og low.
Data out to A0 to match example..
Ny

#### Anish142

#4
##### Feb 16, 2014, 08:43 pm
Thanks, I am still getting negative values. Im not sure as to why this is happening

#### knut_ny

#5
##### Feb 16, 2014, 08:47 pm
small nes is OK .
Change the numer 511 up/down a litte till you get 0 out when still.
Ny

#### Anish142

#6
##### Feb 16, 2014, 08:54 pm
thanks it works now. It moves about 1-2 everytime I shake it. Is this expected? thanks for your help.

#### knut_ny

#7
##### Feb 16, 2014, 08:58 pm
OK... you mangage to shake it with 2G..
Tap it on the table.. you'll reach 10G+ (if program reads at the right momemt)

This sensor is best used to measure akseleration in rockets at launch..
..or inn collision tests
Ny

Go Up