Show Posts
Pages: 1 ... 6 7 [8] 9 10 ... 14
106  Using Arduino / Programming Questions / Re: Transferring data to Android - ADB, Processing on: March 21, 2013, 03:28:44 pm
The code is only part of it and it is dependent on the communication shield you add to your arduino (WIFI, ethernet, bluetooth etc, serial..)...
The code you showed doesn't make any sense in context.
107  Using Arduino / Programming Questions / Re: I2C Arduino Uno Problem on: March 20, 2013, 02:17:59 pm
Quote
you usually send 0x00 first to the device to tell it to get ready.

not all devices needs this, best to check the datasheet for your specific device(s).  smiley-grin

yup. I have a sensor where I need to send 4 bytes first, not just 0x00. It depends.
108  Using Arduino / Programming Questions / Re: I2C Arduino Uno Problem on: March 20, 2013, 01:32:30 pm
Here's an example
http://arduino.cc/en/Tutorial/SFRRangerReader

you usually send 0x00 first to the device to tell it to get ready.
And you'll need Wire.endTransmission() at the end.
109  Using Arduino / Programming Questions / Re: many WTF error about variable on: March 20, 2013, 01:25:31 pm
Is there a guide on how to debug? Some of you gurus should write something.

I assume you mean "debug" compiler errors.


Compiler errors and compiled bugs. It would be nice to know what all those error messages mean. It is an art to know how to debug. I work with Xcode sometimes and it's a pleasure to debug on that IDE.
110  Using Arduino / Programming Questions / Re: Timing on sensor issue on: March 20, 2013, 11:58:49 am
Thanks. I think those are the answers.
111  Using Arduino / Programming Questions / Timing on sensor issue on: March 20, 2013, 11:31:06 am
Hi,
My main sketch loop() has a delay(1) but I have a CO2 sensor that can't be read no faster than every 5 seconds, it'll error out otherwise. I can't change my delay to 5000 because that would make the whole app unresponsive.

I do have an RTC hooked up and I was thinking along the lines of
Code:
void loop() {
   getCO2();
   delay(1);
}

double getCO2() {
  if (RTC.second%5 == 0) {
    //read CO2 sensor
    return co2
  }
}

But the problem is if you call getCO2() at the wrong time, you're out of luck. I'd want to to return something on every call.
Or if I just use a while loop somehow without freezing up the app for 5 seconds?

thanks.
112  Using Arduino / Programming Questions / Re: How to create a function dynamicaly ? on: March 20, 2013, 10:09:00 am
Here's the basics on how to build a library
http://arduino.cc/en/Hacking/LibraryTutorial

You'd want to study how the TimeAlarms library do its stuff.
With the newest ide, you can use the c++ 'new' and 'delete' operators to create and delete objects. You don't have to use malloc.
I'd store the instances in an array and loop through it to perform things.
113  Using Arduino / Programming Questions / Re: Syntax for arrays as operands on: March 20, 2013, 09:59:09 am
I'm not 100% sure what you're asking but you can write overriding functions with the same name that expect different parameters.

Code:
void setup() {
  func(1,2);
  func();
}

void loop() {
}

void func(int a, int b) {
 // do stuff with a & b
}

void func() {
   // nothing
}
114  Using Arduino / Programming Questions / Re: How to create a function dynamicaly ? on: March 20, 2013, 09:01:48 am
I think you'll need write your own library. No, you can't dynamically write function but what you want to do is possible.

You'd want a class where to can pass in timed events and info of other devices you want to control, maybe an array of pins or object of devices.
115  Using Arduino / Programming Questions / Re: How to create a function dynamicaly ? on: March 19, 2013, 11:31:10 pm
You're thinking of what I'm working on right now. I'm creating a device class with a timer method in it. Ever time I want to add a new device, I create a new instance of the device with new parameters etc..
In your case, you would add a new instance of a timed event.

I found this project that might help you out
http://code.google.com/p/ebl-arduino/wiki/RTCTimedEvent
116  Using Arduino / Programming Questions / Re: How to expose instance to be used by another class on: March 19, 2013, 10:43:52 pm
Thanks. That did it. I just needed to #include the DS1307.h.

I'm already extending 2 other classes. I thought doing this way would be easier since the DS1307 can have a constructor and can be accessed on the main sketch too.
117  Using Arduino / Programming Questions / How to expose instance to be used by another class on: March 19, 2013, 09:21:21 pm
Hi,
I have a RTC class that has an extern instance.
Code:

class DS1307
{
......
}
extern DS1307 RTC;

And I have another class wanting to get the time from this class by calling RTC.getTime() and so on. I found out this is not enough, I'd get an "'RTC' was not declared in this scope" error.
So how do I make it so RTC.getTime() can be called from anywhere from another class to the arduino sketch?

Maybe make getTime() a static method and not do an instance RTC?

thanks.
118  Using Arduino / Programming Questions / Re: many WTF error about variable on: March 19, 2013, 03:19:05 pm
Is there a guide on how to debug? Some of you gurus should write something.
119  Using Arduino / Programming Questions / Re: I know little about programming, and have a specific question. on: March 18, 2013, 07:24:00 pm


I thought you're going off a tutorial.
Here's instructions on for loop
http://arduino.cc/en/Reference/For
120  Using Arduino / Programming Questions / Re: I know little about programming, and have a specific question. on: March 18, 2013, 07:20:06 pm
Code:
    for(i=0;i”);

source of your error
Pages: 1 ... 6 7 [8] 9 10 ... 14