Adding ADXL3xx accelerometer example; minor comment changes.

This commit is contained in:
David A. Mellis 2008-07-02 19:06:27 +00:00
parent 0bdc02cea5
commit 278872728a
4 changed files with 58 additions and 6 deletions

View File

@ -56,7 +56,7 @@
productName = App;
productReference = 33DD8FB6096AC8DA0013AF8F /* Arduino.app */;
productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>CFBundleDevelopmentRegion</key>
@ -687,6 +687,7 @@
33FFFD3F0965B1E40016AC38 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 33FFFD400965B1E40016AC38 /* Build configuration list for PBXProject "Arduino" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 0;
mainGroup = 33FFFD3D0965B1E40016AC38;
productRefGroup = 33FFFD3D0965B1E40016AC38;
@ -879,13 +880,13 @@
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "";
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = "";
JAVA_CLASS_SEARCH_PATHS = "../shared/lib/registry.jar ../shared/lib/antlr.jar ../shared/lib/mrj.jar ../shared/lib/RXTXcomm.jar ../shared/lib/oro.jar";
JAVA_COMPILER_SOURCE_VERSION = 1.4;
JAVA_COMPILER_TARGET_VM_VERSION = 1.4;
JAVA_ONLY = YES;
JAVA_SOURCE_SUBDIR = .;
OPTIMIZATION_CFLAGS = "-O0";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
@ -912,7 +913,7 @@
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
OPTIMIZATION_CFLAGS = "-O0";
GCC_OPTIMIZATION_LEVEL = 0;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";

View File

@ -0,0 +1,47 @@
// ADXL3xx
//
// Reads an Analog Devices ADXL3xx accelerometer and communicates the
// acceleration to the computer. The pins used are designed to be easily
// compatible with the breakout boards from Sparkfun, available from:
// http://www.sparkfun.com/commerce/categories.php?c=80
//
// http://www.arduino.cc/en/Tutorial/ADXL3xx
// Breakout Board Pinout
// 0: self test
// 1: z-axis
// 2: y-axis
// 3: x-axis
// 4: ground
// 5: vcc
int groundpin = 18; // analog input pin 4
int powerpin = 19; // analog input pin 5
int xpin = 3; // x-axis of the accelerometer
int ypin = 2; // y-axis
int zpin = 1; // z-axis (only on 3-axis models)
void setup()
{
Serial.begin(9600);
// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop()
{
Serial.print(analogRead(xpin));
Serial.print(" ");
Serial.print(analogRead(ypin));
Serial.print(" ");
Serial.print(analogRead(zpin));
Serial.println();
delay(1000);
}

View File

@ -42,6 +42,8 @@ unsigned long millis()
unsigned long m;
uint8_t oldSREG = SREG;
// disable interrupts while we read timer0_millis or we might get an
// inconsistent value (e.g. in the middle of the timer0_millis++)
cli();
m = timer0_millis;
SREG = oldSREG;
@ -57,7 +59,7 @@ void delay(unsigned long ms)
;
}
/* Delay for the given number of microseconds. Assumes a 16 MHz clock.
/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock.
* Disables interrupts, which will disrupt the millis() function if used
* too frequently. */
void delayMicroseconds(unsigned int us)

View File

@ -6,11 +6,11 @@ Add highByte(), lowByte(), and makeWord(high, low) functions.
Add bitRead() and bitWrite() functions (and bitSet() and bitClear()?)
Add Encoder library.
Add String library.
Add Servo library.
Comment LiquidCrystal examples.
Write LiquidCrystal documentation.
[done] Move #include <WProgram.h> after other #include's? (prevent it from interfering with standard libraries)
[done] Add LiquidCrystal library.
[done] Add Servo library.
[done] Fix millis() so it overflows on a nice variable-size boundary; see: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205949448
[done] Factor out print statements into a common base class for Serial, LiquidCrystal, etc.
@ -38,6 +38,8 @@ Supporting EEMEM directive by changing compiler command line: http://www.arduino
Include Arduino as AVR-ISP sketch in hardware/firmwares.
Move type definitions into WConstants.h.
Change core to use Arduino types (e.g. byte, boolean).
Fix millis() so it never increments by two.
Consider moving millis() to timer 1, and configuring it so the interrupt is generated once a millisecond.
COMPUTER
@ -128,4 +130,4 @@ Show a picture of the LED flashing.
DOCUMENTATION / TROUBLESHOOTING
Add explanation of how to work around auto-reset.
Add explanation of how to work around auto-reset.