Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Programming Questions / Re: Serial.begin confusion on: March 03, 2013, 04:29:24 am
It's the communication speed. Doesn't really matter, except that the serial monitor may default to 9600 baud and you'll see garbage in there if the rate didn't match.

Edit: Yea, well, it does matter, but I hope you get the point..
17  Using Arduino / Programming Questions / Re: For ,While Loop , can't get it work on: March 03, 2013, 03:10:25 am
Yes, so, to people who are writing example codes for the usage of the library they have just implemented, please stop adding the never-ending while(1) loop in the loop function.. Or is there some specific reason for writing examples like this? :p It'll just get dragged into coding practices of new coders for no reason.
18  Using Arduino / Programming Questions / Re: Programming Style on: March 03, 2013, 03:03:32 am
Code:
void function_name(parameters)
{
   function definition ;
}

To me, this is the way I code, and i'd refuse to do it any other way.

That's what I use too but without the extra space between the definition and semicolon. I can live with the awkward way of putting opening and closing semicolons on different levels if that's what the IDE auto-formatting tool does. As long as the code looks consistent in this way, I'm ok with it.

As for wasted lines, that's not so important these days. The extra empty lines give the code some rhythm so to say, within reason of course, and makes the code easier to read to me. I add extra empty lines into the function just to improve readability so the so called wasted line from the placing of the opening semicolon is really not that relevant a question to me.
19  Using Arduino / Programming Questions / Re: from Arduino to a local host on: March 02, 2013, 05:42:43 am
In networking localhost just refers to the local machine, whatever it is. If you send something to localhost by name or IP address (eg 127.0.0.1), it does not really get routed anywhere but the local machine. It'll just connect directly to the service, like the webserver, bypassing some of the layers that it would otherwise have gone through and putting less load on the network interfaces. Also called the loopback address.
20  Using Arduino / Programming Questions / Re: PROBLEM IN UPLOADING on: March 02, 2013, 05:26:29 am
Can you upload anything to that board? Even just the blink example? Or is just with this wiring and this code? I'm asking because of some of my uploading problems were related to me plugging some IRQ line into the wrong microcontroller pin. Sometimes Windows would just say the device has malfunctioned and it would get disconnected, and other times Arduino IDE would pass along some sync error.

Please don't use all caps.
21  Using Arduino / Programming Questions / Re: While loop do not work or maybe ram overflow? on: March 02, 2013, 05:17:21 am
As was already suggested, break the menu function down into smaller functions. You'd have a single function for each different menu, or you could event take the contents from an array with a single function that is parametrized with current selection. Either way, you have duplicated practically the same piece of code multiple times, separately for each button press too, and you are still missing the F macro from most of the strings.
22  Using Arduino / Programming Questions / Re: Delays and unsigned long on: March 02, 2013, 04:55:04 am
Well, under a topic that says "Delays and unsigned long" in this sub-forum, one may not expect to see an impressive picture book like that on a drink machine. Looks great. Good work! smiley
23  International / Scandinavia / Re: GPS venemittaristoa (Versio 1.0 nyt toiminnassa). on: February 28, 2013, 03:21:58 pm
No hyvä että nyt toimii. Minäkin hommasin LCD:n, eikä sekään sitten edes toiminut.. pitää viritellä paremmalla kärsivällisyydellä joskus myöhemmin.
24  Using Arduino / Programming Questions / Re: need help storing text to scroll through 10lines on 4 line lcd display on: February 28, 2013, 03:18:05 pm
how do i get the lcddisplay to know about them?
Simplest way to do that I see you kind of already did. Declare them outside the function at the top with the rest of the variables. It should work, but you had some problem with it. A more complex for you maybe, is to pass them by reference to lcddisplay function while still keeping them as local variables. The third way is to add a static keyword to the declaration. Might work, but lcddisplay still might not see it if the function is declared higher. Then there's of course forward declaration that could get rid of that kind of problems - add an extra: void lcddisplay(); at the top and then leave the function definition where it is.
Quote
i will try and clean up my code and get rid of some unwanted curly brakets if i can.
Well, some of those curly brackets are actually required within the switch case if you declare a variable in there. But a few of them look a little out of place and I couldn't catch where the other end of the "context" defined by those brackets was.. Or, you can just select Tools/Auto format in Arduino IDE and it'll do the work for you. It's easier to catch context problems when the code is formatted and indented in a consistent way.
25  Using Arduino / Programming Questions / Re: Counter to 480 on: February 28, 2013, 03:03:18 pm
Why 480? Why not just do 1 to 10? Anyways, you can make a for loop from 1 to 480, increase by one, take modulo (% 10) and whenever that hits 0, you increase another integer by 1 that decides which led should be turned on now. Or you could do without the expensive modulo, increase by ten each round, or whatever. However, efficient design kinda requires knowledge on how did you wire the LED's and what makes you insist on counting up to 480. Maybe you have shift register or a few, and in that case I would do a little bit of bit math to light the leds.
26  Using Arduino / Programming Questions / Re: need help storing text to scroll through 10lines on 4 line lcd display on: February 28, 2013, 02:45:08 pm
Those local variables line1, 2 and 3 are falling out of context so to say, and lcddisplay does not know anything about them. Then you are also referring to line4 and 5 that are never declared even locally. Another thing to note is that you are referring to character in index 9 in those arrays, why? What's so special about index 9? Even if it was special, you are still referring to newcard[9] before the value in that index was set to a new value. You also have a few extra curly brackets in the middle and the indentation makes it a little difficult to read, so I was unable to put my full concentration into interpreting what the code is supposed to be doing, sorry..
27  Using Arduino / Programming Questions / Re: Programming ??? Math Question on: February 28, 2013, 02:24:03 pm
Now that I think about, I've never actually tried to do an increment operation on a floating point number. I would have tried something like t+=1.0f myself not knowing would the post increment operation also work. Then again, you could implement a line drawing algorithm using integers for efficiency, but I suppose I'm only nitpicking here.. Also, ya-yb is a negative, is that what you intended in your design? Maybe that's the key problem here..
28  Using Arduino / Programming Questions / Re: Programing a Mrico on: February 24, 2013, 01:45:35 am
When you plug in a different board, the COM port most likely changes. The old port disappears from the menu, but the UI does not really tell you that on a glance - it just un-selects the port, and tells you a lie on the status bar.

Another annoying thing is that if you plug in two boards and intend to program one program on the first instance of the IDE, and another on the second instance, it's using the same setting for both of the IDE's forcing you to change the board type and port every time you are switching between the instances and uploading the program.
29  Using Arduino / Programming Questions / Re: Passing I/O functions to a class. on: February 23, 2013, 03:33:28 pm
Like declaring Menu class based on serial class?
(Just learned that Serial is not the class, so maybe it is 'serial'?).

But what if the menu wants to read from Serial, but display informations somewhere else and then the errors on...?
Serial port are instantiated from a class already, so it's not necessary to derive from them.

For example, from Arduino reference:
"All Arduino boards have at least one serial port (also known as a UART or USART): Serial."
"The Arduino Leonardo board uses Serial1 to communicate via RS232 on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication."

Anyways, if I'm reading this correctly, it looks like the instantiation is done in HardwareSerial.cpp/.h from a class named HardwareSerial into instances Serial, Serial1, and so on. This is included from Arduino.h so, at least you can trust that they are always accessible hardware supporting.. Since the Serial classes are already instantiated in memory, you should just pass the related instances by reference to save memory unless you insist on overriding some functions like read and write. Outside Arduino IDE this probably works in a different way.

However, my point about function pointers was that it kinda doesn't belong in C++ when you have other neater ways of doing the same thing in my opinion. Function pointers are typically used in C when you need to collect actions in an array and pass them into function calls. Nothing stops you from doing the same within a class though. It's a separate topic from above because I don't see what would the passed function be.
30  Using Arduino / Programming Questions / Re: Problem compiling when adding code for a 2nd tact button to act as a switch. on: February 23, 2013, 05:29:31 am
You are still missing the digitalRead that sets reading2, methinks.
Pages: 1 [2] 3 4 ... 6