Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 15
61  Using Arduino / Programming Questions / Re: NEED HELP FAST!!!!! on: September 19, 2012, 04:43:37 pm
oh and also he did this

if (blabla==blblblb); {  }
note that red ; is wrong

if (your logical test here){actions sperated by; like another one here;}

if you logical test is more complex you can nest them like this if((a==b)||(c==d)){do things;}
62  Using Arduino / Programming Questions / Re: "Immunity-aware programming" on: September 19, 2012, 10:28:37 am
i am not 100% sure but here an advice if your device operates near people and might harm them. (note that arduino shouldnt be used in such environment)
however in such environments and as an addded saferty like such environments.

Besides electrical discharge, it it is for safety reasons then your sensor output to keep a machine going should always be on (provide signal).
In other words if you loose signal the device should stop whatever it is doing.
So even an "on" button cannt be a single push signal, and there cannt be a on signal to turn something off in a flow of behaviours.
no signal is then interprented as broken signal, and thus a reason to stop or to behave different.

63  Using Arduino / Programming Questions / Re: How to save a constant updating value on: September 13, 2012, 05:25:28 pm
hmm some side notes.
So the angle is from a device (bike) that can turn over (fall)..

Hmm it might be hard to balance something if thats your goal.
There are accellero meters and there are things who precizely measure an angle but no acceleration.
The math to balance is kinda complex dough there was an article recently i tink on "hack a day" website..
Dough, it might perhaps be an idea to not use complex math for it, but train a more general neural net (there is even a neural net example for arduino)
Training dough will require a lot of falling, but eventualy by learning such software will work (hey even you i can walk by using our real neurons).
I remember for (real) long time ago such neural software has been used on targeting rockets, and kept better track under real world conditions (wind, unstable engines etc).
It wont be easy but.. if learning was your goal.. there is a lot one can learn from it.
64  Using Arduino / Programming Questions / Re: Multi-dimensional byte array Init on: September 12, 2012, 04:35:52 pm
hm, this might have to do something with the scope of the code, i wonder.
Usually libraries contain functions, and do things separately from main code
It might be that the values are private only available in your library itself.

this might interest you  
there are other methods too   [url][/ur]
depending on the code one could keep values inside the library (and have functions exposed of how to respond*.) or expose variables like the alphabet to outside the library.

*Like Send(pin,"SOS") and    msg=Read(pin)
65  Using Arduino / Programming Questions / Re: How to save a constant updating value on: September 12, 2012, 06:04:50 am
ehm the code idea i presented allowed for defining a moment when the button is active
the push button would only become active again after a specific condition
isnt that what your looking for ?
66  Using Arduino / Programming Questions / Re: How to save a constant updating value on: September 11, 2012, 04:41:57 pm
Its not exactly clear to me what you want to achieve, but i believe maybe an extra variable could help here.
Below i give a sample based on your code, it might not be complete because i'm not sure what you try to do.

Well here is how it can work for you, use another variable in which you track when its OK to use the activate button.
While readkey = false you wont go into the condition where you store your angle data.
Only when both are true you store your data, so when its not true you only check for the condition of readkey, at certain angle become true..

i placed it all in an if construction, perhaps you might consider while too, but not sure if the code had to keep running (e.e so it wont lock inside a loop) below code wont lock / halt inside a function.

// put in setup
Boolean readkey = true;

// put in main...

val = digitalRead(button); //Read input

if ((val==True) ||(readkey==True))
 {    // i asume code below is what you want to happen when things are true
   Serial.write(0xFE);   //command flag
    Serial.write(192);    //position
    readkey = false;    //ADDED
  if (readkey==false) { //here you can decide when to enable the readkey
                                 if (yourvalue =< ???? ){ readkey = true; Storemyvalue = ?????}                          

67  Using Arduino / Programming Questions / Re: Multi-dimensional byte array Init on: September 11, 2012, 10:35:31 am
why do you need a multiple dimensioned array to create morse code ???
be aware that such arrays use a lot of memory.

you only need to store short long and empty so  01 11 00 is enough.
If you want to improve you better create something that also does improve for example by using less memmor

the letters are made of 4 signals, so in essence you could do this with just 1 byte per letter character. ( A = 01 11 00 00) equals 112
such alfabet stored in bytes would only require 24 bytes, thats a lot less memory.

Only numbers require 5 signals so you cannt store them in a single byte (5*2 bits =10 bits).
However numbers have a simple presentation invent a function to write and read them.. also not that complex.
68  Using Arduino / Programming Questions / Re: Passing char arrays to a function - best practice on: September 11, 2012, 04:40:41 am
maybe its more handy to know what pointers are.
suppose that you do something like this

int A = 10;

Then well thats easy a variable A got assigned a value of 10
But computers dont store the whole alphabet, and your "A" is just easy to read and handy to work with.
In reality this "A" is stored somewhere.
Imagine if the arduino memory where a street, each house might contain some value like an "A".
Now the easiest way to retrieve those values would be if someone told you to go to the address of a house and retrieve what it has stored.
This address points you to where it is stored, so POINTERS simply refer to places in memory.

There is a lot of fun that you can do with pointers, because they are not only used for simple variables
One could store also an object in an house, and that object could contain more values, like your array.

But there are even more interesting things you might store in a house
For example you could put in an object that not only contains an some value, but also the address of the next house to visit and the previous house, and maybe even the house address of the first sidelane.
Such more complex objects allow for the creation of database like structures.. In fact databases are made like that.

So from something simple as a pointer, you can get into complex stuff and store any kind of information structure.

Now the speed you get from it is that you only have to refer to something by a pointer and dont have to cast it into another variable for some complex things (like your function).
And well it might look a bit scary, its to good to learn about this topic a bit. There are things you can do with it for wich they are handy.

69  Using Arduino / Programming Questions / Re: Analogwrite problem on: September 10, 2012, 05:27:37 pm
please use code tags when posting
ehm did you forgot // marks in your setup part.
is see you also use it once / but it should be double //
oh and i think analog write can only have values between 0 and 255
70  Using Arduino / Programming Questions / Re: Passing char arrays to a function - best practice on: September 07, 2012, 08:14:29 am
please try to adjust your sendmsg function like this, i believe it should work.
void SendMsg(char * myMsg)    // << points to your array and that should be enough, a basic c++ method
  char MsgAndTime[strlen(myMsg) + 10];  
  strcpy(MsgAndTime, myMsg);  
  strcat(MsgAndTime, " 1:00 PM");

notice only the main calling method is changed the way you would if calling for an array function variable.
if it doesnt work then arduino isnt c++ compliant but i dont doubt it wouldnt work like this.
71  Using Arduino / Microcontrollers / Re: next Arduino board on: September 06, 2012, 03:55:17 pm
yeah well we see that the arm processors these days have usb support in arduino (leonev) but hm i see also chips like some atmel chips have it inside.
72  Using Arduino / Microcontrollers / next Arduino board on: September 06, 2012, 03:25:01 pm
Well i wonder is Teensy 3.0 the next major arduino release (based on its specs), it seams quite something special

Or will there be a wifi enabled next major board?.
73  Using Arduino / Programming Questions / Re: How to send http strings on: September 04, 2012, 05:28:59 pm
try fidler  instal it on your pc to findout the requred commands its a IExplorer add on 
or use netmon if your into networking
74  Using Arduino / Programming Questions / Free 3 year license for visual studio 2010 on: September 04, 2012, 10:15:16 am
i stubled on this news announcement
After you have it you can use to work on sketches from within visual studio c++
Visual studio is an excelent programming editor, note however that arduino c++ editor tool starts up a bit faster.
But visual studio is a profesional programming packet (not limited to only arduino or only c++)
75  Using Arduino / Programming Questions / Re: For loops?? on: September 03, 2012, 06:22:05 pm
ok just wrote something simple.. you can ad more if lines if you have more leds, code is real short i guess it should work, not tested it.
int pin1=1;
int pin2=2;
int x =0;

// a short method using modulo function >> % <<

void loop(){
if(x%3==0)   {state1=!state1;digitalWrite(pin2,state2);}
if(x%13==0) {state2=!state2;digitalWrite(pin2,state2);}

Pages: 1 ... 3 4 [5] 6 7 ... 15