debugging

i need help in getting this program to work. at present it is having errors. i am trying to interface accelerometer adxl345 (inactivity interrupt) with arduino. the program is given below.

#include <SPI.h>
int cs = 10;
int intr = 2;
int buzzer = 4;
int relay = 5;
int su = 1;
int intr1
pinmode (buzzer,OUTPUT);
pinmode (relay,OUTPUT);
char POWER_CLT = 02D
char DATA_FORMAT = 0
31
char DATAX0 = 032
char DATAX1 = 0
33
char DATAY0 = 034
char DATAY1 = 0
35
char DATAZ0 = 036
char DATAZ1 = 0
37
char THRESH_ACT = 024
char THRESH_INACT = 0
38
char TIME_INACT = 026
char INT_ENABLE = 0
2E
char INT_MAP = 02F
char ACT_INACT_CTL = 0
27
char INT_SOURCE = 0*30

char values[10];
char output[20];
int x, y, z;
char inactivityevent = 0;
void setup()
{
SPI.begin();
SPI.setDataMode(SPI_MODE3);
Serial.begin(9600);
pinMode(cs,OUTPUT);
digitalWrite(cs, HIGH);
attachInterrupt(digitalpintointerrupt(intr),interruptHandler,RISING);
writeRegister(DATA_FORMAT,001);
writeRegister(POWER_CTL,0
08);
writeRegister(INT_MAP,0F7 && 0EF);
writeRegister(THRESH_INACT,1);
writeRegister(TIME_INACT,0);
writeRegister(ACT_INACT_CTL,00F);
writeRegister(INT_ENABLE,0
08);
readRegister(INT_SOURCE,1,VALUES);
}

void interrupHandler()
{
read register (INT_SOURCE,1,values);
}

void loop()
{
intr1=digitalread(intr);
if ( intr1==high)
{
read register(DATAX0,6,values);
x = ((int)values[1]<<8|(int)values[0]);
y = ((int)values[3]<<8|(int)values[2]);
z = ((int)values[5]<<8|(int)values[4]);
if ( x<=15 && x>=-15 && y<=10 && y>=-10 && z>=75 && z<=90)
{
digitalwrite(buzzer,HIGH);
digitalwrite(relay,LOW);
}
else
{
for (int i=0;i<=90;i++)
{
delay (2000);
if (intr == LOW)
{ break(); }
if (i==90)
digitalwrite(relay,LOW);
}
}
while (su=1)
{
if (intr==LOW)
{
digitalwrite(buzzer,LOW);
digitalwrite(relay,HIGH);
break();
}
}
}
}

at present it is having errors.

And they are . . ?

Please please use code tags when posting code

Like this if ( intr1==high)
Oops

Which character do variable declarations end with ?

Just to help AWOL a bit :smiley:

Arduino: 1.6.6 (Windows 8), Board: "Arduino/Genuino Uno"

test:21: error: exponent has no digits

                                                                         char INT_ENABLE = 0 * 2E

                                                                                               ^

test:39: error: invalid digit "8" in octal constant

   writeRegister(POWER_CTL, 0 * 08);

                                ^

test:44: error: invalid digit "8" in octal constant

   writeRegister(INT_ENABLE, 0 * 08);

                                 ^

test:8: error: expected initializer before 'pinmode'

 pinmode (buzzer, OUTPUT);

 ^

test:9: error: expected constructor, destructor, or type conversion before '(' token

 pinmode (relay, OUTPUT);

         ^

test:10: error: unable to find numeric literal operator 'operator"" D'

 char POWER_CLT = 0 * 2D

                      ^

C:\Users\sterretje\Documents\Arduino\Projects\Forums\test\test.ino: In function 'void setup()':

test:37: error: 'digitalpintointerrupt' was not declared in this scope

   attachInterrupt(digitalpintointerrupt(intr), interruptHandler, RISING);

                                             ^

test:37: error: 'interruptHandler' was not declared in this scope

   attachInterrupt(digitalpintointerrupt(intr), interruptHandler, RISING);

                                                ^

test:38: error: 'DATA_FORMAT' was not declared in this scope

   writeRegister(DATA_FORMAT, 0 * 01);

                 ^

test:38: error: 'writeRegister' was not declared in this scope

   writeRegister(DATA_FORMAT, 0 * 01);

                                    ^

test:39: error: 'POWER_CTL' was not declared in this scope

   writeRegister(POWER_CTL, 0 * 08);

                 ^

test:40: error: 'INT_MAP' was not declared in this scope

   writeRegister(INT_MAP, 0 * F7 && 0 * EF);

                 ^

test:40: error: 'F7' was not declared in this scope

   writeRegister(INT_MAP, 0 * F7 && 0 * EF);

                              ^

test:40: error: 'EF' was not declared in this scope

   writeRegister(INT_MAP, 0 * F7 && 0 * EF);

                                        ^

test:41: error: 'THRESH_INACT' was not declared in this scope

   writeRegister(THRESH_INACT, 1);

                 ^

test:42: error: 'TIME_INACT' was not declared in this scope

   writeRegister(TIME_INACT, 0);

                 ^

test:43: error: 'ACT_INACT_CTL' was not declared in this scope

   writeRegister(ACT_INACT_CTL, 0 * 0F);

                 ^

test:43: error: unable to find numeric literal operator 'operator"" F'

   writeRegister(ACT_INACT_CTL, 0 * 0F);

                                    ^

test:44: error: 'INT_ENABLE' was not declared in this scope

   writeRegister(INT_ENABLE, 0 * 08);

                 ^

test:45: error: 'INT_SOURCE' was not declared in this scope

   readRegister(INT_SOURCE, 1, VALUES);

                ^

test:45: error: 'VALUES' was not declared in this scope

   readRegister(INT_SOURCE, 1, VALUES);

                               ^

test:45: error: 'readRegister' was not declared in this scope

   readRegister(INT_SOURCE, 1, VALUES);

                                     ^

C:\Users\sterretje\Documents\Arduino\Projects\Forums\test\test.ino: In function 'void interrupHandler()':

test:50: error: 'read' was not declared in this scope

   read register (INT_SOURCE, 1, values);

   ^

test:50: error: expected ';' before 'register'

   read register (INT_SOURCE, 1, values);

        ^

C:\Users\sterretje\Documents\Arduino\Projects\Forums\test\test.ino: In function 'void loop()':

test:55: error: 'intr1' was not declared in this scope

   intr1 = digitalread(intr);

   ^

test:55: error: 'digitalread' was not declared in this scope

   intr1 = digitalread(intr);

                           ^

test:56: error: 'high' was not declared in this scope

   if ( intr1 == high)

                 ^

test:58: error: 'read' was not declared in this scope

     read register(DATAX0, 6, values);

     ^

test:58: error: expected ';' before 'register'

     read register(DATAX0, 6, values);

          ^

test:59: error: 'values' was not declared in this scope

     x = ((int)values[1] << 8 | (int)values[0]);

               ^

test:64: error: 'digitalwrite' was not declared in this scope

       digitalwrite(buzzer, HIGH);

                                ^

test:74: error: expected ';' before '(' token

           break();

                ^

test:74: error: expected primary-expression before ')' token

           break();

                 ^

test:77: error: 'digitalwrite' was not declared in this scope

           digitalwrite(relay, LOW);

                                  ^

test:84: error: 'digitalwrite' was not declared in this scope

         digitalwrite(buzzer, LOW);

                                 ^

test:86: error: expected ';' before '(' token

         break();

              ^

test:86: error: expected primary-expression before ')' token

         break();

               ^

exit status 1
exponent has no digits

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Nah, serious.
I would start fixing the missing semicolons. You would see the below if you auto-format the code in the IDE. Incorrect indentations are an indication of a missing semi-colon, curly etc.

char POWER_CLT = 0 * 2D
                 char DATA_FORMAT = 0 * 31
                                    char DATAX0 = 0 * 32
                                        char DATAX1 = 0 * 33

An other error is referring to octal numbers. If you use a number like 01, the compiler expects an octal number; 08 is not a valid octal number.

Why do you use something like char DATAX0 = 0 * 32; would it not just be easier to write char DATAX0 = 0;?

And 2E is not a hexadecimal number, it is a double that is missing an exponent.