How to modify accelerometer code for propeller demo board and tV display?
I have LIS3LV02DQ accelerometer and found that Jomo already generate code for this.
But, I noticed that My propell demo board has different pin#, and I don't have LED display. My propell demo board has pin0~P7, while JoMo used p10, 11, 12 in his code for Clk and SOD and CS.
Q1)Can I just modify the pin from 10, 11, 12 to saying 1, 2, 3, then revise the code accordingly?
Q2) I don't have LED and have TV terminal. Can someone show me how I can modify the code for TV terminal out instead of LED in the code?
Thanks,
![jumpin.gif](http://forums.parallax.com/images/smilies/jumpin.gif)
But, I noticed that My propell demo board has different pin#, and I don't have LED display. My propell demo board has pin0~P7, while JoMo used p10, 11, 12 in his code for Clk and SOD and CS.
Q1)Can I just modify the pin from 10, 11, 12 to saying 1, 2, 3, then revise the code accordingly?
Q2) I don't have LED and have TV terminal. Can someone show me how I can modify the code for TV terminal out instead of LED in the code?
Thanks,
![jumpin.gif](http://forums.parallax.com/images/smilies/jumpin.gif)
JoMo said...
Hi,
Ah ha! The final thing·was that the powerUp bit was not being set! By default this thing is powered down.
Here is my code that works.
deSilva cheers to you·again.· The Forum at it's best.
Much thanks!
-Joe [noparse]:)[/noparse]{{ LIS3LV02DQ Test LIS3LV02DQ Vdd -> Prop Vdd -> +3v LIS3LV02DQ Gnd -> Prop Vss -> -gnd. LIS3LV02DQ SDA -> Prop pin 10 [s](pulled high)[/s] seems to work fine without pullup. LIS3LV02DQ SCL -> Prop pin 11 [s](pulled high)[/s] seems to work fine without pullup. LIS3LV02DQ CS -> Prop pin 12 LIS3LV02DQ INT -> NC LIS3LV02DQ SDO -> NC LIS3LV02DQ CK -> Nc }} CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 'OLED ISTEXT = 0 ISNBR = 1 TINY_FONT = 0 WITH_AMB = 1 RAW = 0 O_TX = 7 O_RX = 6 O_RS = 5 'accelerometer A_SDA = 10 A_SCL = 11 A_CS = 12 A_Addr = %00111010 OBJ OLED : "uOLED-128-GMD1" A_I2C : "i2cobject" DELAY : "Clock" VAR byte dispX byte dispY byte reds[noparse][[/noparse]255] byte greens[noparse][[/noparse]255] byte blues[noparse][[/noparse]255] PUB main OLED.INIT(O_TX,O_RX,O_RS) OLED_SETUP cls print(TINY_FONT,0,255,0,string("Testing..."),ISTEXT,0) A_I2C.Init(A_SDA,A_SCL,false) dira[noparse][[/noparse]A_CS]~~ outa[noparse][[/noparse]A_CS]:=1 ' SPI=0 , I2C=1 delay.pausesec(1) writeRegister($20,%01000111) ' power up! ctr reg1 printRegister($20,true) ' ctr reg1 delay.pausesec(3) repeat printRegister($28,true) ' high byte of x output printRegister($29,true) ' low byte of x output printRegister($2A,true) ' high byte of y output printRegister($2B,true) ' low byte of y output printRegister($2C,true) ' high byte of z output printRegister($2D,true) ' low byte of z output delay.pausesec(1) cls pri printRegister(register, isNewLine) | c register |= %10000000 c:=A_I2C.readLocation(A_ADDR,register,8,8) print(c,TINY_FONT,0,255,0,ISNBR,isNewLine) pri writeRegister(register,value) register |= %00000000 A_I2C.writeLocation(A_ADDR,register,value, 8,8) pri showAccDevicePresent | c c:=a_i2c.devicePresent(A_ADDR) print(c,TINY_FONT,0,255,0,ISNBR,true) pri OLED_SETUP OLED.ERASE DELAY.PauseMSec(20) OLED.BACKGROUND(0,0,0) pri cls oled.erase dispX:=0 dispY:=0 pri print (text,FONT, R,G,B, dTYPE,ISNEWLINE) OLED.FTEXT(dispX,dispY,FONT,R, G,B,text,dTYPE) dispX += strsize(text) if(ISNEWLINE) newLine handleCursor pri newLine dispY++ dispX:=0 pri handleCursor if(dispX > 20) dispY++ dispX:=0 if(dispY > 14) delay.pausesec(1) cls
Comments
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother LLC (SMT Assembly Services)