|
CLASS DOCUMENTS
REPORTS & ASSIGNMENTS
CLASS CONTENT
USING THIS SITE
registered authors login here You are: (logout) For more on PMWiki, see pmwiki.org |
ADXL 202 PicBy Grace Kim This PicBasic Pro code reads an ADXL202 accelerometer on two pins of a PIC and outputs the values serially. It only outputs the raw values, it does not convert them to acceleration values or G-force values. DEFINE OSC 4 xTilt VAR WORD yTilt VAR WORD XPin VAR portc.2 ' connected to X axis pin of accelerometer YPin VAR portc.3 ' connected to Y axis pin of accelerometer tx VAR portc.6 rx VAR portc.7 n9600 CON 16468 inbyte VAR BYTE PAUSE 500 main: SERIN2 rx, n9600, [inbyte] PULSIN XPin, 1, xTilt PULSIN YPin, 1, yTilt SEROUT2 tx, n9600, [xTilt.HighByte, xTilt.LowByte, yTilt.HighByte, yTilt.LowByte] PAUSE 100 GOTO main |