ok… so i am trying to incorporate using the SRF08 ultrasonic sensor to my hex. Im using the usual setup - BB2 and basic atom pro.
I found some sample code for the basic atom on the net and changed it slightly for the pro (SDA and SCL pin numbers) but having problems compiling it!
SDA Con P6 ’ Define Data pin
SCL Con P7 ’ Define Clk pin
SRF08 Con 0xE0 ’ Sonar I2C Address
CmdReg Con 0 ’ Sonar Command register
LightReg Con 1 ’ Sonar Light sensor register
RangeReg Con 2 ’ Sonar 1st Range register
Light Var Byte ’ Light sensor
Range Var Word ’ 16 bit variable for Range
Main
i2cout SDA, SCL, SRF08, CmdReg, [81]
pause 66
i2cin SDA, SCL, SRF08, LightReg, [Light, Range.HighByte, Range.LowByte]
Serout S_OUT, i9600, “Light1 = 0x”, HEX Light, ", Range = ", DEC Range, " cm, "] ’ Use terminal window
goto main
the problem is:
Error: FILE C:\PROGRAM FILES\BASICMICRO\BASIC MICRO STUDIO\TESTMORE\I2C.BAS(LINE 26) : [TOKEN CMDREG] : Expected
line 26 corresponding to the i2cout part - at the CmdReg bit i think. as far as i can tell its in the right format for an i2cout command but if im missing something could you guys please help? many thanks.
the ‘81’ at the end corresponds to a request for the result in centimeters from the sensor.
Any help would be greatly appreciated