H48C Library

The H48C Library for H48C 3-axis sensor by parallax

How To Install

Download here: H48C version 1.0

Put the H48C folder in your Arduino "libraries".

In the Arduino IDE, create a new sketch (or open one) and

select from the menubar "Sketch->Import Library->H48C".

Once the library is imported, a "#include H48C.h" line will appear at the top of your Sketch.

Setup

The schematic of the H48C has 6 pins. 5 are used with the Arduino. The White dot on the module is located next to pin 1. Here is the Pin descriptions:

  • pin 1 = CLK
  • pin 2 = DIO
  • pin 3 = Ground
  • pin 4 = Not Used
  • pin 5 = CS
  • pin 6 = V++

H48C::H48C(int CSpin, int CLKpin, int DIOpin)

This is the setup construct. The pin data is required.

Methods

int::getX()

This returns the current Gravitational value for the X axis. Normal values range from - 300 to 0 to + 300. Normal G value will be 100.

int::getY()

This returns the current Gravitational value for the Y axis. Normal values range from - 300 to 0 to + 300. Normal G value will be 100.

int::getZ()

This returns the current Gravitational value for the Z axis. Normal values range from - 300 to 0 to + 300. Normal G value will be 100.

Example : Display Gravitation Force

/*
H48C - Example for H48C 3-axis sensor by parallax
Ported from kiilo killo@killo.org
by Dan McClain daniel.e.mcclain@gmail.com
Released into the public domain.
*/

#include <H48C.h>

//pin setup
int CSpin = 9;
int CLKpin = 10;
int DIOpin = 11;

//variable setup

//object setup
H48C h48c(CSpin, CLKpin, DIOpin);


void setup(){
  Serial.begin(115200);
}

void loop(){
  Serial.print("X: ");
  Serial.print(h48c.getX());
  Serial.print("  ");
  Serial.print("Y: ");
  Serial.print(h48c.getY());
  Serial.print("  ");
  Serial.print("Z: ");
  Serial.print(h48c.getZ());
  Serial.println();
  delay(1000);
}

Version

1.0 2011/09/27 Initial Release

Contact

Dan0nator daniel.e.mccclain@gmail.com

Share