Show Posts
Pages: 1 ... 9 10 [11] 12 13 ... 15
151  Using Arduino / Programming Questions / Re: Arduino Communication Crashes after some time Running on: July 11, 2012, 05:01:28 pm
Maybe you didnt want this

Reading in your code i see contador ++ in your main loop
I guess you wanted some delay before calling that action if (contador>20)...
However note that adding +1 to a int value will go fine, until it reaches the maximum value of an int.
After that it simply starts over counting from zerro again  > and so you code to enable communication (and state check) is run again
not sure if you intended it but then  Comunicando = ~Comunicando; is called again too

did you want a small delay or is it okay to do this (because i'm not speaking the language its bit harder to see what you want).

It can also be that buffers on the computer side fill up (or data logging becomes to much, computer out of disk space, and computer becomes non responsive). Other option can indeed be, that power is not stable enough, both computer and arduino relay on stable power.
Zener diodes can give pretty stable power, wont protect i think for HF noice, Elco's can do that, magnetic on radio radiation is another thing.
if people do arch-welding nearby.. then thats terrible for electronics..
152  Using Arduino / Programming Questions / Re: declare 1 pin on 2 names on: July 11, 2012, 04:42:04 pm
well essentially
you set a variable name to 35 and you use it to refer to the 35th pin (arduino mega i guess it has lots of pins)
Variables can have the same name, i'd prefer logical small names, but you can call variables how you want compilers dont use these name in the final compiled code.

what you do next is saying that a certain pin number,   the pin number 35 as described by this variable ,  will be set to OUTPUT mode.

It is not forbidden to do so, in most programs its not practical.
There you just make a setup in which you define how the pins or ports (whatever you call them) should react.
But you can create program that sets pins on specific connected devices.

In such case you might as well use arrays, and use a while loop to set each pin for specific connected devices.
For example
array int Board1 [34,35,12,11,10'] // use a loop to set each port number 
array int board1 [  1,  1,  1, 0, 1]  // if value is 1 set it as output, 0 for input, ...

i use this sometimes to set many specific pins for output.

Note you have to make something for selecting your board because if one board uses a pin for input and another for output.. then you cannt call them just right after eachother, then the last call on how you want to set the board will be the one that is active.

maybe use a serial connection read, (connected to a computer) listen for a board name, and then set the pins like that
once you have them set you wont do this again '(simply dont send it again)
depending on name create a
If (boardname =="yourboard"){ //do this routine for setting up pins};
boardname = "" ; //clear variable so line above wont run again.
153  Using Arduino / Programming Questions / Re: [Arduino Vs Android] Open accessory protocol problem on: July 11, 2012, 04:11:57 pm

i dont think these are yet for sale ? (and not even mentioned on this site)

154  Using Arduino / Programming Questions / Re: [Arduino Vs Android] Open accessory protocol problem on: July 11, 2012, 01:22:44 pm
Wow you have a googleIO developers day android bord   !! ??  (how did you get it?)

the forum is pretty silent about future arduino development boards, i assume its a next level board type.
If you went to google's IO days, didnt you got a CD with programming samples ?

155  Using Arduino / Programming Questions / Re: Convert String to int on: July 11, 2012, 07:08:39 am
int convert (string x) {
  int n = 0;
  char c= " ";
  for (int i=0;x.length;i++){
    c = x.charAt(i);
    n = n*10;
    n = n +int(c)
return n;

or simple  n= int(string); wont work ??
156  General Category / General Discussion / arduino in space... ! on: July 11, 2012, 06:38:08 am
I was reading this story

its a bit above my budget.. but its kinda cool
so.. if you can program an arduino..
your now a potential satellite programmer..

 smiley-lol How does it feel to be a rocket scientist?  smiley-lol
157  Using Arduino / Project Guidance / voice for arduino on: July 10, 2012, 07:54:39 pm
i've been wondering if voice would be possible for arduino.
by using a fractal as a generator for a pwn pin (0..255) output for voice singnal

i'm not deeply into fractals, but i like to drop the idea here

Words can be split up in phonons , small vocal parts.
there are too many of them to store on an arduino's memory
thats where a fractal can come in handy give it a start and an end number and it will produce a pattern
my thinking is (wrong or not?) that eventually a fitting patern for each phonon could be found
and thus a phonon can then be described in a start number and end number of the fractal function

main problem.. the right fractal for the task  / another computer prog to find the phonoms inside the fractal
158  Using Arduino / Programming Questions / Re: Motors Library: Counting # of steps on: July 10, 2012, 06:40:44 pm
not sure how your program looks like
if one cycle takes 55 steps and you have a loop for it somewhere after each loop increase a counter cycle

if it is based on the loop with an ever increasing counter
then there is the modulo function   --->    %

if( counter % 55==0){cycle++;}
159  Using Arduino / Programming Questions / Re: Image on web on: July 09, 2012, 07:17:18 pm
you might try to use dropbox / from matlab save to your public dropbox folder / right click it there, to get the web url
use the web url in your arduino shield page /... (dont store it on your arduino)
160  Using Arduino / Programming Questions / Re: Please modify this code on: July 09, 2012, 07:05:48 pm
yes in this case its more handy to write it like that, less typing is better.

But suppose you wanted a more complex function to create a complex string for HTML formatting.
Based on the value of A the text color is red or green, and if A is below or above a treshold it should be bold too.
Things like that require longer peaces of code.

As i am not sure how good you are in coding, i just noted it could also be written as your function, with a name you like to add to it.
If your learning c++ from other languages, it might be confusing to see how functions are made.
Without words like "Function" , well c++ is a bit barebones syntax , compared to languages like python  or java or basic, or ...etc

Essentially   int() is a build in function for arduino its allready there.
161  Using Arduino / Programming Questions / Re: Please modify this code on: July 09, 2012, 01:59:31 pm
a small extra note
if you want a function to go from a string to number it goes like this

int ConvertStringToInt(string S)
   return int(s);

As mentioned earlier there is always one answer to a function so you could repeat it
If you have this function you can write

A = ConvertString(lux_v1);
B = ConvertString(lux_v2);

in this case its more typing work, but often functions are good to repeat complex computer math programming, so using functions is a good thing just to let you know  smiley-grin

162  Using Arduino / Programming Questions / Re: Please modify this code on: July 09, 2012, 01:45:29 pm
oh your realy new to code.. well ehmm you should dive into it why else you have an arduino?.
I dont have the ethernet shield so i cannt really rewrite and test your code.
Well maybe i still can help you, and give you guidance
As a general note type correctly
As i see in your code
int lux_v1 = readString.substring(7, 11);
int lux_v1 = readString.substring(12, 16);// lux_v2 = readString.substring(12, 16)
i added some marked command  // is for marking
in you code you give lux_v1 a value and the next line does the same to the same value
But most likely you wanted it to assign to lux_v2

Are those perhaps the values you would like to work with ?
Because there you took parts of string called readString
For strings, a string = "text like this"
The first character is counted as zero
So the command substring, takes from readstring the 0123456 7th  character till the 11th
However by nature if you take part of a string it will returned as a string to you.
There is a function to convert a number inside a string to an int
// put this in the setup part
int A = 0; 
int B = 0;
now you program knows of two variables A and B
You also had lux_v1 and lux_v2 who where not int's but strings
This how you get their text numbers into an int, place it in your main program below after where i spoted your typo.
A = int(lux_v1);
B = int(lux_v2);

Instead of A you might also name them like Lux_v1_AsNumber  perhaps more easy?

I also note that you use a function called    atoi()  as far as i know this is not part of the arduino language, i couldnt find a reference of it (there is no atoi here : but perhaps its a function that was part of Spi or Ethernet includes ? well perhaps might be.

Oh nextyou have serial output... and web output.
So you should also upate your webpage with A and B i suppose ?
Take a look at your seccond usage of your  <body> statement ... that should be </body>
But just above that line you might write
client.println (<br>);  // in html web page language that is a new line
client.print ( "First value :");
client.print ( lux_v1 );  // yes we can keep the string, you might try int version too
client.print (<br>);
client.print ( "Second value :");
client.print ( lux_v2 );

I hope you will manage with this help, i cannt test your solutions.
What's always a good approach to programming is to divide your problems into smaller ones. Or slowly extend your program, with a lot of file saves in between. so your working code extends, until you reach a problem. so then you know its there. then try to solve it in small parts, look perhaps how other people solved similar c++ coding problems, hang around c++ forums, or place newbie questions at   "stack overflow"  >> google it.
You can also slowly extend the sample programs its a good way to learn how to code.
Books are nice too,  (but borring too) just try to code, thats where it all starts..
163  Using Arduino / Programming Questions / Re: why does it work this? on: July 09, 2012, 10:34:22 am
a stroke.. hmm your a bit like me constant headache..
maybe a mistake of syntax under c++,
i am aware of a few strange ways of typing in c++
but have not seen something like you typed.

int x=3;

x +=2; // is same as x=x+2;   results in 5

x *=2 ; // performs the operation x = x * 2 results in 6  if x still was 3

x++;  // x =  x + 1

doing a multiply in front of a variable that you would like to assign a value..
dont think its part of c++  ?
164  Using Arduino / Programming Questions / Re: Please modify this code on: July 09, 2012, 10:13:57 am
String s = "123,456";               // string
int i = s.indexOf(",");
int l = s.length();
int a = int(s.substring (0,i-1));  //result in a
int b = int(s.substring (i+1,l));  //result in b

ps check for typos, as i didnt  
Sorry lazy.. but maybe you where too ?
Or maybe not, your new to coding, well then i gave a sample.
165  Using Arduino / Programming Questions / Re: How to detect if the board is connected to PC? on: July 08, 2012, 07:56:55 pm
Perhaps try to think outside of the box.. dont detect it.
You might write to both usb and to the SD you do it in a circular logging way. (FILO)
Circular logging is sometimes used in databases to have some time window to be able to restore data
Ofcourse its not the best.. but its better then nothing, and it might be all you want.
That is if you do not have to much data (or else your SD will be full quickly)..but it will always overwrite oldest data (so there is a time limit of how much data can be recovered back in time)..
Also keep in mind how often you can rewrite your SD...
If it is important data get it to a networked file cluster or so ..

Not sure how SD storage works (i dont have it)
if you have a file system on it, then keep a pointer to oldest write somewhere, and update it once you overwrite your oldest stored data samples. (circular logging).
When connected to PC perhaps also store a date time on the SD
Perhaps use clock shield or so.

You might have 2 arduino's around, another one to replay a SD to your compter, to restore data
or write a program that replays trough a comlink to fool the original computer program

PS for medical data it might not be wise to use an arduino, see its license its not to be used in environments that could change the dead or alive situation of a carbon based life form..or something like that.
Ask yourself what is the cost if your solution would fail, its not foolproof hardware it will brakedown someday

PS It might interest you to read about atomic databases  (no its not about physics) >Exchange uses it.
Pages: 1 ... 9 10 [11] 12 13 ... 15