mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
First integration of the Arduino code in Processing 5503: PreProcessor and Compiler have been integrated with changes to the Sketch.
Compilation still has problems (Thread error on success, and can't handle non-pde files in a sketch). Modified the Mac OS X make.sh to copy the hardware, avr tools, and example over. Removing some of the antlr stuff. Disabling the Commander (command-line execution) for now. Added Library, LibraryManager, and Target. Added support for prefixed preferences (e.g. for boards and programmers).
This commit is contained in:
43
build/shared/examples/Sensors/Memsic2125/Memsic2125.pde
Normal file
43
build/shared/examples/Sensors/Memsic2125/Memsic2125.pde
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Memsic2125
|
||||
*
|
||||
* Read the Memsic 2125 two-axis accelerometer. Converts the
|
||||
* pulses output by the 2125 into milli-g's (1/1000 of earth's
|
||||
* gravity) and prints them over the serial connection to the
|
||||
* computer.
|
||||
*
|
||||
* http://www.arduino.cc/en/Tutorial/Memsic2125
|
||||
*/
|
||||
|
||||
int xpin = 2;
|
||||
int ypin = 3;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
pinMode(xpin, INPUT);
|
||||
pinMode(ypin, INPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int pulseX, pulseY;
|
||||
int accX, accY;
|
||||
|
||||
// read pulse from x- and y-axes
|
||||
pulseX = pulseIn(xpin,HIGH);
|
||||
pulseY = pulseIn(ypin,HIGH);
|
||||
|
||||
// convert the pulse width into acceleration
|
||||
// accX and accY are in milli-g's: earth's gravity is 1000.
|
||||
accX = ((pulseX / 10) - 500) * 8;
|
||||
accY = ((pulseY / 10) - 500) * 8;
|
||||
|
||||
// print the acceleration
|
||||
Serial.print(accX);
|
||||
Serial.print(" ");
|
||||
Serial.print(accY);
|
||||
Serial.println();
|
||||
|
||||
delay(100);
|
||||
}
|
Reference in New Issue
Block a user