Show Posts
Pages: [1]
1  Using Arduino / Sensors / Accelerometer ADXL 335 on: August 31, 2011, 01:19:18 pm
Hello.
I'm doing an object that will behave differently depending on the side that is on. I'm using an ADXL 335 accelerometer and, on the sample code that is on the arduino website the values are normal and I implemented a version of it that works perfectly. The problem is when I put the code into the bigger code that has all the other behaviours the values of the Accelerometer change.... in exactly the same position... in one (the original arduino sample) the value is of 500 and when is on the other the value is 280..

Does anyone have an Idea why might this be?
2  Using Arduino / Programming Questions / Re: declaration of '' as array of functions on: August 15, 2011, 12:37:51 pm
Thanks, that helped


I'm now having a problem with the values that I have as null

Code:
if (myColourControl != null )
      {
        pulse_my_colour();
        resetTargetControl();
      }

in here myColourControl is declared on top as a int myColourControl[3];

I'm getting the error that the null wasn't declared on this scope. The null is "lighting up" as a variable from arduino language :s what can it be?
3  Using Arduino / Programming Questions / declaration of '' as array of functions on: August 15, 2011, 05:46:17 am
hello.

I'm trying to adapt a code that a friend helped me to do in processing to arduino. The code is basically changing the colors of a background in processing and doing some fades depending on the keys pressed. In the arduino I'm getting the colors from the database using the wifly shield and some inputs of the accelerometer.

the problem I'm gaving now is that one of the functions of the processing code my friend did is returning an array

Code:
int[] get_colour(int side)
    {
      int[] value = new int[3];
   
      if (side == 1) {
        value[0] = 255;
        value[1] = 0;
        value[2] = 100;
      }

the way you declare arrays on arduino is different so my guess was to do this

Code:
int get_colour[](int side)
    {
      int value[] = new int[3];
   
      if (side == 1) {
        value[0] = 255;
        value[1] = 0;
        value[2] = 100;
      }

but I'm getting the error " declaration of 'get_colour' as array of functions"

which makes sense.... but how can I make that function return this array of value?

4  Using Arduino / Programming Questions / Re: Wifly shield read from database every 10 seconds on: August 11, 2011, 11:15:20 am
Thanks a lot. I'm going to try it now. I didn't know about the largest value being that.
As for the client.flush() it was because I thought the reason was because it was saving the data from before... stupid assumption.

Thanks again.
5  Using Arduino / Programming Questions / Wifly shield read from database every 10 seconds on: August 11, 2011, 05:51:37 am
Hello. I'm a newbie in arduino.
I'm trying to make the wifly shield read from a local database every ten seconds. I managed to do this by using a conditional if in the millis() and adding the value I wanted to wait until it loaded again to a variable like this:

if (millis() >= updateTime) {
updateTime += 10000;
}

the problem I'm having is that the arduino reads from the database and "updates" 2 times and then it stops.

this is my code
Code:
#include <_Spi.h>
#include <Client.h>
#include <Configuration.h>
#include <Debug.h>
#include <ParsedStream.h>
#include <Server.h>
#include <SpiUart.h>
#include <WiFly.h>
#include <WiFlyDevice.h>

// (Based on Ethernet's WebClient Example)

#include "WiFly.h"


#include "Credentials.h"


//byte server[] = { 194,80,29,91 }; // Google
//byte server[] = { 66, 249, 89, 104 }; // Google
byte server[] = {169,254,195,202 }; // Google

Client client(server, 80);
char c ;

int updateTime = 0;
int redPin =  3;    // LED connected to digital pin 13
int greenPin =  5;    // LED connected to digital pin 13
int bluePin =  6;    // LED connected to digital pin 13

//Client client("169.254.97.89/emotize", 80);
//Client client("http://www.google.com", 80);
//Client client("http://www.sandrobrt..com", 80);

void setup() {
  //------- for LED
 
  pinMode(redPin, OUTPUT);   
  pinMode(greenPin, OUTPUT);   
  pinMode(bluePin, OUTPUT);   
 
 
  // ---- for Wifi
 
 
  Serial.begin(115200);
  Serial.println("WebClient example at 38400 baud.");

  WiFly.begin();

  if (!WiFly.join(ssid)) {
    Serial.println("Association failed.");
    while (1) {
      // Hang on failure.
    }
  } 

  WiFly.configure(WIFLY_BAUD, 38400);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");

    client.println("GET /get2.php?id_reciever=2 HTTP/1.0");

    client.println();
  } else {
    Serial.println("connection failed");
  }
 
}

int count = 0;
int plus = 0;

void loop() {
if (millis() >= updateTime) {
    client.flush();
    client.stop();
    WiFly.begin();
     if (!WiFly.join(ssid)) {
    Serial.println("Association failed.");
  } 
  WiFly.configure(WIFLY_BAUD, 38400);
  Serial.println("connecting...");
  if (client.connect()) {
    Serial.println("connected");
 
    client.println("GET /get2.php?id_reciever=2 HTTP/1.0");
    client.println();
  }else {
    Serial.println("connection failed");
  }

    updateTime += 10000;
  }
      current_state();
}


void current_state(){
    if (client.available()) {
     c = client.read();
    Serial.print(c);
    count++;

  }
   if(isDigit(c)) {
//            Serial.println(c);
    int number = int(c);
//  Serial.println(number);

    if(number == 49){//1
        analogWrite(redPin,0);
        analogWrite(greenPin,0);
        analogWrite(bluePin,0);
        analogWrite(redPin, 255);
        analogWrite(bluePin, 100);
     }
       if(number == 50){ //2
        analogWrite(redPin,0);
        analogWrite(greenPin,0);
        analogWrite(bluePin,0);
        analogWrite(redPin, 255);
        analogWrite(greenPin, 75);
     }
       if(number == 51){//3
        analogWrite(redPin,0);
        analogWrite(greenPin,0);
        analogWrite(bluePin,0);
        analogWrite(bluePin, 255);
     }
       if(number == 52){//4
        analogWrite(redPin,0);
        analogWrite(greenPin,0);
        analogWrite(bluePin,0);
        analogWrite(redPin, 255);
     }
       if(number == 53){//5
        analogWrite(redPin,0);
        analogWrite(greenPin,0);
        analogWrite(bluePin,0);
        analogWrite(greenPin, 255);
     }
       if(number == 54){//6
        analogWrite(redPin,0);
        analogWrite(greenPin,0);
        analogWrite(bluePin,0);
        analogWrite(redPin, 255);
        analogWrite(bluePin, 255);
       
     }
     
 

//  plus = 0;
//  }
 
    }
 
 
 
// 
//  if (!client.connected()) {
//    Serial.println();
//    Serial.println("disconnecting.");
//    client.stop();
//    for(;;)
//      ;
//  }

}


If someone knows what the problem is let me know please.

I tried to use the client.flush() because I guess that it's just saving unnecessary data but with it the program doesn't run properly.

thanks in advanced

Sandro Brito
6  Using Arduino / Interfacing w/ Software on the Computer / Re: Creating setup Software for arduino based prototype of a product on: July 31, 2011, 02:12:26 pm
I guess so. Thanks, I'll look into that possibility!
7  Using Arduino / Interfacing w/ Software on the Computer / Re: Creating setup Software for arduino based prototype of a product on: July 31, 2011, 01:58:56 pm
Sorry if I didn't explain it right.
Basically I want to do an application that inputs the sketch into the arduino ( just like the IDE does) where people have the option to write they're passwords and choose their wifi network. This will be done by usb!

In short, it's almost like creating a mask to put on top of the IDE with the options of changing those variables on the credentials.h

Hope this is more clear
8  Using Arduino / Interfacing w/ Software on the Computer / Creating setup Software for arduino based prototype of a product on: July 31, 2011, 01:22:22 pm
Hello guys.
I'm doing a prototype of a smart object that uses a Wifly Shield.
I need to create a "Setup Software" so that when I show the prototype to the teachers ( It's for an MA final project) I can Set it up into the network. Basically what I need to do is alter the file of the credentials.h to put the ssid and password of the network the object is going to connect and then when people hit the ok button it would upload into the arduino just like the IDE does.
Does anyone have any idea how can I make this?
Thanks in advanced.
Pages: [1]