Show Posts
Pages: 1 2 [3] 4 5 ... 136
31  Using Arduino / Programming Questions / Re: help coding spectrum analyzer on: February 17, 2011, 10:35:10 pm
Slightly easier to compile:
Code:
const int led6 = 6;
const int led7 = 7;
const int led8 = 8;
const int led9 = 9;
const int led10 = 10;
const int led11 = 11;

int led6intensity= 0;
int led7intensity= 0;
int led8intensity= 0;
int led9intensity= 0;
int led10intensity= 0;
int led11intensity= 0;

void setup () {
    pinMode(led6,OUTPUT);
    pinMode(led7,OUTPUT);
    pinMode(led8,OUTPUT);
    pinMode(led9,OUTPUT);
    pinMode(led10,OUTPUT);
    pinMode(led11,OUTPUT);
}

loop(){
    led6intensity = analogRead(0); //left
    led7intensity = analogRead(1) //right
    led8intensity = analogRead(3); //left
    led9intensity = analogRead(4); //left
    led10intensity = analogRead(5); //left
    led11intensity = analogRead(6); //left
   
    analogWrite(led6, led6intentsity);
    analogWrite(led7, led7intentsity);
    analogWrite(led8, led8intentsity);
    analogWrite(led9, led9intentsity);
    analogWrite(led10, led10intentsity);
    analogWrite(led11, led11intentsity);
}
32  Using Arduino / Programming Questions / Re: sending flow back to the Loop() on: February 17, 2011, 06:57:41 pm
You can use return; to exit a function. If that function is called from the loop() then you will return to loop.
33  Using Arduino / Programming Questions / Re: Help with MenuBacked lib + LCD and Keypad on: February 16, 2011, 06:34:26 pm
Code:
menu.getCurrent()
  smiley
34  Using Arduino / Programming Questions / Re: Help with MenuBacked lib + LCD and Keypad on: February 16, 2011, 06:05:11 pm
Sorry, I think you need &Set_Date. Did you look at my examples? I think I do this there. (examples for the menubackend)
35  Using Arduino / Programming Questions / Re: Help with MenuBacked lib + LCD and Keypad on: February 16, 2011, 04:29:39 pm
What works, and what does not?

Try:
Code:
switch(used.item) {
  case Set_Time: /*your actions here*/ break;
}

I don't know what to help you with, but I'll give it a try if you explain it (again) smiley
36  Using Arduino / Programming Questions / Re: Which Library Development Environment? on: February 15, 2011, 04:43:02 pm
Being a Computer Science student and professional developer (shock!) I'm not much interested in plugging in hardware and mashing together bits of other people's code. I want to write it all from scratch!
This probably what most of us CS geeks thinks (especially while we're students), but it will get you nowhere in the real life. Actually, it will get you somewhere, and that is last.
UNLESS you're lucky enough to discover something no one has ever done before.

The sooner you learn the skill to 'mashing together bits of other people's code' the sooner you will become a great developer.
 smiley
37  Using Arduino / Programming Questions / Re: Problem with my code. on: February 15, 2011, 01:12:36 pm
If you don't care about any results / data from the function, you can put 'void' there instead.

Not to nitpick, but a void does not indicate that one does not care. It explicitly restricts the function to not return anything.
You can easily call a function that return something, and call it without caring about the results / data:
Code:
add(1,2); //call a function that return something, without caring
smiley
38  Using Arduino / Programming Questions / Re: Which Library Development Environment? on: February 15, 2011, 10:57:11 am
I use Notepad++ and logic. If you design your program first, on paper or using some tool on the computer, you might cut the cycle drastically.
A lot of my libraries are written cycling just once: http://arduino.cc/playground/Profiles/AlphaBeta

You should try to become your own compiler, and embed a lot of mental cues in your code.
If you once have a bug because you do if (x = 42) and meant if (x == 42)then adopt a convention to always  start with the constant like if (42 = x) which will be an error, and it looks like an error as well, right? Then you spot that, and correct it to if ( 42 == x) without the need for a complete cycle.
Always comment code that are not self descriptive and that use many language constructs (no need to comment that a getChar method gets a char, and it is no need to comment that i++ increments i).

I also find that it's a good exercise to manually run through the code, as a personal core review and a verification that the logic is sound.


Good luck! Writing libraries for the Arduino has thought me a lot, I'm sure it will teach you a lot as well.
Any problems? Just ask smiley
39  Using Arduino / Programming Questions / Re: how to separate events on: February 15, 2011, 10:43:46 am
http://www.arduino.cc/playground/Code/TimedAction#Example

You could also use that library to create some timed actions/kernels/loops (whatever you call them).
40  Using Arduino / Programming Questions / Re: Newbie question about arrays on: February 14, 2011, 08:56:28 pm
If the 'inner dimention' aka [][this] has 8 or less elements, you could back them in a single byte.

Anyways, you need to either:
Code:
//declare & define
boolean arr[SIZE_X][SIZE_Y] = {
  { 1,0,0,1 },
  { 0,0,1,1 },
  //ETC ETC
};
Code:
//declare
boolean arr[SIZE_X][SIZE_Y];

//later on, 'add value' or rather set the value at element 0,1 to true
arr[0][1] = true;
41  Using Arduino / Programming Questions / Re: Trying to make program menu with LCD 16X2 + Keypad 4X4 on: February 14, 2011, 07:11:02 pm
You could have a look at this library: http://arduino.cc/playground/uploads/Profiles/MenuBackend_1-5.zip

It helps with managing menu logic navigation and hierarchical structure.
42  Topics / Robotics / Re: Arduino Controller on: February 14, 2011, 06:52:57 pm
The standard  mega328 based arduino board has 19 I/O pins
Hmmm, 14 + 6 is 20?
43  Using Arduino / Programming Questions / Re: Help me With My Code! on: February 13, 2011, 06:58:10 pm
Not unless you only light up ONE led at the time.
44  Using Arduino / Programming Questions / Re: Problem with Code: Arduino unable to multiply... on: February 13, 2011, 06:57:37 pm
When you divide an integer on something greater than the integer, you will always get 0 when dealing with integers. That's because the decimals get truncated.

Always cast the dividend to a type that handles decimals, in most cases float.
45  Using Arduino / Programming Questions / Re: Problem with Code: Arduino unable to multiply... on: February 13, 2011, 06:54:15 pm
((float)32/FT)
Pages: 1 2 [3] 4 5 ... 136