RedBot
RedBot Arduino Library for the Sparkfun RedBot
 All Classes Functions Variables
RedBotAccel Class Reference

#include <RedBot.h>

Public Member Functions

 RedBotAccel ()
 
void read ()
 
void enableBump ()
 
boolean checkBump ()
 
void setBumpThresh (int xThresh)
 

Public Attributes

int x
 
int y
 
int z
 

Detailed Description

A class for controlling the RedBot's accelerometer.

Since the RedBot's accelerometer uses the I2C protocol, and is only connected to A4 and A5 on the RedBot, there should only ever be a single object of this class instantiated in your application/sketch.

Constructor & Destructor Documentation

RedBotAccel::RedBotAccel ( )

Creates an object of the class RedBotAccel

Member Function Documentation

boolean RedBotAccel::checkBump ( )

Check to see if a "bump" event has occurred.

This method returns true if a "bump" event has occurred since the last time that RedBotAccel::checkBump() has been called. Before using RedBotAccel::checkBump(), bump detection must be enabled via RedBotAccel::enableBump(). Note that a "bump" is an acceleration event that occurs along the X-axis.

void RedBotAccel::enableBump ( )

Enable bump detection.

A "bump" is an acceleration event that occurs along the X-axis. After enabling bump detection, use to RedBotAccel::checkBump() to do the actual detection.

void RedBotAccel::read ( )

Copy the current accelerometer values into the class's attributes.

In order to "read" the accelerometer's current state, you must first call RedBotAccel::read() to set RedBotAccel::x, RedBotAccel::y, and RedBotAccel::z which you can then read and do your own processing.

void RedBotAccel::setBumpThresh ( int  xThresh)

Set the threshold for what is considered a "bump" event.

If the default "bump" event threshold is too strong or too weak for your application/sketch, you can provide a value of 0-127 inclusive to use as the new threshold. Prior to calling RedBotAccel::setBumpThresh(int xTresh) "bump" detection must first be enabled via RedBotAccel::enableBump().

Member Data Documentation

int RedBotAccel::x

Read the last copied X-axis reading.

This class member is set by calling RedBotAccel::read() and can be used to do your own data processing.

int RedBotAccel::y

Read the last copied Y-axis reading.

This class member is set by calling RedBotAccel::read() and can be used to do your own data processing.

int RedBotAccel::z

Read the last copied Z-axis reading.

This class member is set by calling RedBotAccel::read() and can be used to do your own data processing.


The documentation for this class was generated from the following files: