Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Remote Arduino and Xbee to Xbee and Arudion.... on: March 25, 2013, 04:58:09 pm
I want to take this code, witch works off serial input for some other xbee. 




Code:
int LedPin = 13;
 

void setup ()
{
  Serial.begin(9600);
  pinMode (LedPin, OUTPUT);
}
void loop()
{
  int Rx = Serial.read() - '0';
 
  if (Rx == 1)
 {
  Serial.println("Led is on");
 digitalWrite(LedPin,HIGH);
   }
 else if (Rx == 0)
 {
 Serial.println("Led is off");
  digitalWrite(LedPin,LOW);
  }
 else
 {
   Serial.println("Invalid!");
 }
}


 Combine it with this code,  so I don't have to use A push button  {pin 3}.  I can use serial in,  from some other xbee.
What is some good help you can give me to start this, so it will work?



Code:
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };


char DEVID1[] = "xxxxxxxxxxxxxxxx"; //Scenario : "The mailbox is open"





//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3;



 
boolean DEBUG = true;



char serverName[] = "xxxxxxxxxxxxx.com";
boolean pinDevid1State = false;
boolean lastConnected = false;



EthernetClient client;

void setup() {
  Serial.begin(9600);
   pinMode (buttonPin, INPUT);
  pinMode(pinDevid1, INPUT);
 
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
}

void loop()
{
   
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
       
        sendToPushingBox(DEVID1);
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
       
      }
     
     
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
     
     
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}

void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}

2  Using Arduino / Programming Questions / Re: Remote Arduino and Xbee to Xbee and Arudion.... on: March 24, 2013, 04:06:33 pm
What about this one.


Code:
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };


char DEVID1[] = "xxxxxxxxxxxxxxxx"; //Scenario : "The mailbox is open"




int pinDevid1 = HIGH;





 
boolean DEBUG = true;



char serverName[] = "xxxxxxxxxxxxx.com";
boolean pinDevid1State = false;
boolean lastConnected = false;



EthernetClient client;

void setup() {
  Serial.begin(9600);

{
 




 
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
{

void loop();
{

  int Rx = Serial.read() - '0';
{
  if (Rx == 1)
     digitalWrite(pinDevid1,HIGH);
   }
   if (Rx == 0)
 {

  digitalWrite(pinDevid1,LOW);
  }




{
   
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
       
        sendToPushingBox(DEVID1);
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
       
      }
     
     
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
     
     
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}

void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}
3  Using Arduino / Programming Questions / Re: Remote Arduino and Xbee to Xbee and Arudion.... on: March 24, 2013, 04:01:23 pm
Here this right now.....



Code:
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };


char DEVID1[] = "xxxxxxxxxxxxxxxx"; //Scenario : "The mailbox is open"










 
boolean DEBUG = true;



char serverName[] = "xxxxxxxxxxxxx.com";
boolean pinDevid1State = false;
boolean lastConnected = false;



EthernetClient client;

void setup() {
  Serial.begin(9600);

{
 




 
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
}

void loop()
{

  int Rx = Serial.read() - '0';

  if (Rx == 1)
{
 
 digitalWrite(pinDevid1,HIGH);
   }
   if (Rx == 0)
 {

  digitalWrite(pinDevid1,LOW);
  }




{
   
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
       
        sendToPushingBox(DEVID1);
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
       
      }
     
     
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
     
     
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}

void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}
4  Using Arduino / Programming Questions / Re: Remote Arduino and Xbee to Xbee and Arudion.... on: March 24, 2013, 12:04:45 am
I am bad at explaining what I am trying to do.  So I will give it one more try.  So I put the two programs,  into one.   The serial not working
on the program, what am I missing?






 








Code:
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };


char DEVID1[] = "xxxxxxxxxxxxxxxx"; //Scenario : "The mailbox is open"





//Numeric Pin where you connect your switch
uint8_t pinDevid1 = LedPin;



 
boolean DEBUG = true;



char serverName[] = "xxxxxxxxxxxxx.com";
boolean pinDevid1State = false;
boolean lastConnected = false;



EthernetClient client;

void setup() {
  Serial.begin(9600);

{
  
  pinMode (LedPin, OUTPUT);
}


   pinMode (buttonPin, INPUT);
  pinMode(pinDevid1, INPUT);
  
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
}

void loop()

{
  int Rx = Serial.read() - '0';
  
  if (Rx == 1)
 {
  Serial.println("Led is on");
 digitalWrite(LedPin,HIGH);
   }
 else if (Rx == 0)
 {
 Serial.println("Led is off");
  digitalWrite(LedPin,LOW);
  }
 else
 {
   Serial.println("Invalid!");
 }



{
    
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
      
        sendToPushingBox(DEVID1);
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
        
      }
      
    
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
      
      
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}

void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}
5  Using Arduino / Programming Questions / Remote Arduino and Xbee to Xbee and Arudion.... on: March 23, 2013, 01:20:47 pm
What I am trying to do is,  use one (Xbee and Arduino) to send serial data to (xbee and Arduino).  I have the code working great,  sending serial data from xbee to xbee.   What I don't know how to do is make the code switch, inside of the code.  So what I am looking for help
 on is combining ( Serial Data Input With Push Code).   So If I were to input 5V on (Serial Data Output Code) pin 10.
It would be like putting 5V to  (uint8_t pinDevid1 = 3;) on (Push Code).  But using code to be the switch and not 5V. to
(uint8_t pinDevid1 = 3;) pin 3.




Serial Data Output
Code:
int buttonPin = 10;

void setup ()
{
  Serial.begin(9600);
  
  pinMode (buttonPin, INPUT);
}
int currState;
int prevState = HIGH;

void loop()
{
   currState = digitalRead(buttonPin);
   if(currState != prevState)
   {
      if(currState == HIGH)
         Serial.print('1');
      else
         Serial.print('0');
   }
   prevState = currState;
}














Serial Data Input
Code:
int LedPin = 13;
 

void setup ()
{
  Serial.begin(9600);
  pinMode (LedPin, OUTPUT);
}
void loop()
{
  int Rx = Serial.read() - '0';
  
  if (Rx == 1)
 {
  Serial.println("Led is on");
 digitalWrite(LedPin,HIGH);
   }
 else if (Rx == 0)
 {
 Serial.println("Led is off");
  digitalWrite(LedPin,LOW);
  }
 else
 {
   Serial.println("Invalid!");
 }
}







Push Code
Code:
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };


char DEVID1[] = "xxxxxxxxxxxxxxxx"; //Scenario : "The mailbox is open"





//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3;



 
boolean DEBUG = true;



char serverName[] = "xxxxxxxxxxxxx.com";
boolean pinDevid1State = false;
boolean lastConnected = false;



EthernetClient client;

void setup() {
  Serial.begin(9600);
   pinMode (buttonPin, INPUT);
  pinMode(pinDevid1, INPUT);
  
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  else{
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
}

void loop()
{
    
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
      
        sendToPushingBox(DEVID1);
      }
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
        
      }
      
    
      if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
      
      
      if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}

void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}
6  Using Arduino / Programming Questions / Re: Led on Led send on: February 13, 2013, 09:27:58 pm
I tried this code today on my dryer.  The (Serial.println(val)smiley-wink = 264,  with the dryer off. 
When the dryer was on and running, (Serial.println(val)smiley-wink = 266.   How do I go about making the Piezo sensor,
be more sensitive to the vibrations of the dryer,  when it is on?




Code:
int sensor = 2; // Analog in
int val =0; // Current reading for analog pin

void setup() {
  Serial.begin(9600);
  pinMode(sensor, INPUT);
}

void loop() {
  val = analogRead(sensor);
  Serial.println(val);
  delay(100);
}
7  Using Arduino / Programming Questions / Re: Led on Led send on: February 12, 2013, 05:51:08 pm
To  UKHeliBob

When I use the simple program.  In the ( Serial.println(val)smiley-wink  the val comes up as 264.   When I tap on the  Piezo sensor
the val 873.  So how do I get A constant # for the val?  So I can make the led turn on or off. 
8  Using Arduino / Programming Questions / Re: Led on Led send on: February 11, 2013, 06:21:19 pm
This is all I want from you people.  Piezo sensor, Op Amp and some resistor and going to (analog in) pin 2, to the Arduino.   Take pin2 input and make it running this program,  but when the Piezo sensor is not moving then have one led light up and then turn off.  That is what I want, that I don't know how to program.  If you can help give me good input,  not make fun of me,  you are here to help,  I think.....



Code:
int sensor = 2; // Analog in
int val =0; // Current reading for analog pin
int avg; // Running average of the wave amplitude
int MIDPOINT = 520; // Base reading
const int led1 =  13;



void setup() {
Serial.begin(9600);
avg = MIDPOINT; // set average at midpoint
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}

void loop() {
val = analogRead(sensor);


if (val > MIDPOINT) {
val = val - MIDPOINT;
} else {
val = MIDPOINT - val;
}


avg = (avg * 0.5) + (val * 0.5);

if (avg > 70) {

Serial.println("TAP");


delay(100); //
}
}
9  Using Arduino / Programming Questions / Re: Led on Led send on: February 10, 2013, 07:58:33 pm
How do I read the avg as numbers on the Serial.println. 
10  Using Arduino / Programming Questions / Re: Led on Led send on: February 10, 2013, 07:49:27 pm
Is there A way in my code that I can read the input of the (avg),  and put (if (avg < 22)  digitalWrite(led2, HIGH);





Code:
int sensor = 2; // Analog in
int val =0; // Current reading for analog pin
int avg; // Running average of the wave amplitude
int MIDPOINT = 520; // Base reading
const int led1 =  13;
const int led2 =  8;


void setup() {
Serial.begin(9600);
avg = MIDPOINT; // set average at midpoint
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}

void loop() {
val = analogRead(sensor);


if (val > MIDPOINT) {
val = val - MIDPOINT;
} else {
val = MIDPOINT - val;
}


avg = (avg * 0.5) + (val * 0.5);

if (avg > 70) {
// vibration detected!
Serial.println("TAP");
digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, Low); 

delay(100); //
}
}
11  Using Arduino / Programming Questions / Re: Led on Led send on: February 09, 2013, 01:33:53 pm
I have A  Piezo sensor,  Op Amp and some resistor and going to pin 2, to the Arduino.   

Here is what I am shooting for = http://diy.viktak.com/2012/07/washing...







Op Amp setup
http://www.instructables.com/files/deriv/FAH/K0W2/FOHTR2JS/FAHK0W2FOHTR2JS.MEDIUM.jpg
12  Using Arduino / Programming Questions / Re: Led on Led send on: February 08, 2013, 02:56:28 pm
I am trying to use the  Piezo sensor to read the vibration of the dryer being on and running. 

I want led1 to tell you that the piezo sensor is working and I want led2 to send A 0 or 1 telling you the dryer is off, after it's
full cycle of running. 


here is new code that led1 works good.




Code:
int sensor = 2; // Analog in
int val =0; // Current reading for analog pin
int avg; // Running average of the wave amplitude
int MIDPOINT = 520; // Base reading
int led1 = 13;
int led2 = 8;


void setup() {
Serial.begin(9600);
avg = MIDPOINT; // set average at midpoint
}

void loop() {
val = analogRead(sensor);

// Compute wave amplittue
if (val > MIDPOINT) {
val = val - MIDPOINT;
} else {
val = MIDPOINT - val;
}


avg = (avg * 0.5) + (val * 0.5);

if (avg > 70) {
// vibration detected!
Serial.println("TAP");
digitalWrite(led1, HIGH);
delay(1);
digitalWrite(led1, LOW);
delay(100);
}
}
13  Using Arduino / Programming Questions / Led on Led send on: February 08, 2013, 12:53:25 pm
Hi

I have this dryer that I attach A Piezo sensor,  Op Amp and some resistor.  From the OP Amp to pin 2 of the analog in on my arduino.  So when the dryer is on and running,  the Serial.printIn Reads tap.   

What I need help is with this =  When I turn on the Arduino,  I want (led1) to turn on for 2 sec. then go off.  Than that
same (Led1)  to blink when dryer is on and running,  if dryer is off, no blink.  (Led2) I want to read the dryer state,  from
minute to minute.  If the dryer in the minute is running the (Led2) will be off.  If the dryer is off in that minute to minute, 
then I want the (Led2) to blink of one sec.  and then go off.     

Here is the code.  Its not working all right





Code:
int sensor = 2; // Analog in
int val =0; // Current reading for analog pin
int avg; // Running average of the wave amplitude
int MIDPOINT = 520; // Base reading
const int led1 =  13;
const int led2 =  8;


void setup() {
Serial.begin(9600);
avg = MIDPOINT; // set average at midpoint
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}

void loop() {
val = analogRead(sensor);


if (val > MIDPOINT) {
val = val - MIDPOINT;
} else {
val = MIDPOINT - val;
}


avg = (avg * 0.5) + (val * 0.5);

if (avg > 70) {
// vibration detected!
Serial.println("TAP");
digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, Low); 

delay(100); //
}
}
14  Using Arduino / Programming Questions / MMA7660 Module 3 Axis Accelerometer on: January 30, 2013, 07:25:59 pm
First thing,  I downloaded this github program (link at bottom of page) and tried to put it on my Arduino board.  I upload the
Sketch to the Arduino and it tells me the 'MMA7660' is not a class or namespace.  What am I doing wrong?  Is there A
Tutorial out there to help me upload programs from github, put them
into A sketch to download to me Arduino?



Last thing is when I do get this program from github working,  I want to use the
Shake sensor on the MMA7660 Module 3 Axis Accelerometer.  (as in the #define X_SHAKE 0x80) if that can be done,  I don't know,  that is why I am on here for help........

https://github.com/etrombly/MMA7660
15  Using Arduino / Sensors / Re: 3 axis accelerometer to monitor dryer. on: January 12, 2013, 02:05:53 pm
Is there A way to take the two programs and put them as one. 

The first code is the one that give's me data on the mma7660 3 axis accelerometer.  What I don't know how to
do is get more sensitivity out of the (mma7660 3 axis accelerometer).  Angles and Degree's can't read the dryer when it is
on and running.  I need to read the shaking, little movement and sensitivity of the dryer.  This is what the
(mma7660 3 axis accelerometer) should read as data.


Code:
#include <Wire.h>
#include <MMA7660.h>

void setup()
{
  Serial.begin(9600);
  MMA7660.init();
}

void loop()
{
  int x,y,z;
  delay(100); // There will be new values every 100ms
  MMA7660.getValues(&x,&y,&z);
  Serial.print("x: ");
  Serial.print(x);
  Serial.print(" y: ");
  Serial.print(y);
  Serial.print(" z: ");
  Serial.println(z);



Code:
}static int old_x, old_y, old_z;
int new_x, new_y, new_z;
int delta_x, delta_y, delta_z;
double g;

new_x = analogRead(xPin);
new_y = analogRead(yPin);
new_z = analogRead(zPin);

delta_x = new_x - old_x;
delta_y = new_y - old_y;
delta_z = new_z - old_z;

g = sqrt ( sq(delta_x) + sq(delta_y) + sq(delta_x) );
g /= SENSITIVITY_VALUE;         // convert to real 'g' according to sensor sensitivity;

old_x = new_x;     // remember the value for the next sample
old_y = new_y;
old_z = new_z;

delay (60L * 1000L);   // wait 1 minute
Pages: [1] 2 3