Show Posts
Pages: 1 ... 15 16 [17] 18 19 ... 67
241  Using Arduino / Interfacing w/ Software on the Computer / Re: Duemillanove - Scheduling on: April 17, 2013, 06:58:37 am
If you really want 1ms rates and pre-emption you need to be thinking about interrupts.

If something more like 5-20ms granularity with cooperative run-to-completion scheduling is acceptable, here's a library:

https://github.com/billroy/run

-br
242  Using Arduino / Programming Questions / Re: This code works but there must be a better/more elegant way on: April 17, 2013, 06:54:22 am
This would be a good place to use an "array of structs".  

A struct is a collection of variables that you can treat as a unit.  You could use a struct to represent a channel, with a byte for the channel id, a char* for the name, a float for the value, and so on.

You could then set up a (constant) array of these structs to represent your list of channels.  A particular channel would be specified by the index into the array, a small integer to select the channel.

Then you can simplify your code by replacing all the lengthy per-channel setups with a call to a single function, passing the struct index for the desired channel, that would set up the desired properties like the per-channel setups do now.

Does that make any sense?

-br
243  Using Arduino / Programming Questions / Re: ASCII to int (yes, another one) on: April 16, 2013, 05:45:44 pm
Love a little code golf:

Code:
int gethex(byte which) {
char c = buff[which];
if ((c >= '0') && (c <= '9')) return c - '0'
c = toUpper(c);
if ((c >= 'A') && (c <= 'F')) return c - 'A' + 10;
return 0;
}

...
int red =   (gethex(0) << 4) + gethex(1);
int green = (gethex(2) << 4) + gethex(3);
int blue =  (gethex(4) << 4) + gethex(5);


-br
244  Using Arduino / Project Guidance / Re: CSS sheet via println? on: April 16, 2013, 06:46:05 am
Do the styles work correctly if you save the generated HTML and open the HTML file in a browser? 

If they don't, good for you -- you can debug it with a browser and then back-port the fixes to your Arduino code.

-br
245  Using Arduino / Project Guidance / Re: Web server controled pins - what is the best method? on: April 16, 2013, 06:41:23 am
You asked about Bitlash Commander examples: I keep a copy running at http://bitlash-commander.herokuapp.com if you'd like to kick the tires without an Arduino attached.

-br

246  Using Arduino / Project Guidance / Re: All pins show ground on: April 15, 2013, 07:46:57 am
Did you have a reason to expect something different?

-br
247  Using Arduino / Programming Questions / Re: Int Loop - Noob Question on: April 14, 2013, 06:34:49 pm
Globals are only initialized (by default to zero) once at initialization time, before setup() is called.

If you want to reinitialize a variable at the top of the loop() function, just assign it yourself in the usual way.

-br
248  Using Arduino / Project Guidance / Re: Web server controled pins - what is the best method? on: April 14, 2013, 06:29:07 pm
Well I'm biased, because I wrote a PC-based web control panel server which you can read about here:  https://github.com/billroy/bitlash-commander

Both approaches are workable.  It kind of depends on the tools you like to work with.

-br
249  Using Arduino / Programming Questions / Re: Beginning Code Error Message on: April 14, 2013, 06:25:27 pm
That code breaks here for a different reason: TABLE_ENTRIES is not defined.

If you share the actual code that generated that error you might get better help.

-br
250  Using Arduino / Networking, Protocols, and Devices / Re: HTTP GET Request results in 400 Bad Request on: April 14, 2013, 03:48:46 pm
What does the error log on the hosting side say?  It may have a clue why that URL isn't correct.

-br
251  Using Arduino / Programming Questions / Re: unknown message on: April 14, 2013, 09:11:09 am
That code works fine here (tested on serial monitor) on an old Duemilanove with a '328.

What kind of Arduino do you have?

-br
252  Using Arduino / Programming Questions / Re: unknown message on: April 14, 2013, 08:26:35 am
It would be helpful to see exactly what text is sent…

-br
253  Using Arduino / Programming Questions / Re: unknown message on: April 14, 2013, 08:17:59 am
I don't see your bug yet, unless you send more than 10 characters between angle brackets.  

But there is a bug in such a case: if you send more than 9 characters you'll overflow the inData buffer and overwrite index, which is the sort of thing that can lead to the weird behavior you're seeing.  

It's best to check to see if there's room in a buffer before adding a character to it.

-br
254  Using Arduino / Interfacing w/ Software on the Computer / Re: A fatal error with Arduino and Python on: April 14, 2013, 07:14:35 am
Now I get it.  You want the Python program to reconnect to the Arduino when it's unplugged and then plugged back in.

I've never got unplug/replug detection working in Python.  It would go something like this: You'd need to detect the closing of the port (and the disappearing of its com port or device file), wait for its reappearance, and re-open it as you currently do.

You might get some coding ideas from this python network proxy I published on GitHub: https://github.com/billroy/serial-network-proxy/blob/master/bitty.py


-br

255  Using Arduino / Networking, Protocols, and Devices / Re: Network on: April 14, 2013, 06:30:55 am
Your Arduino code, acting as a client, can use HTTP GET and POST requests to fetch and update data on your external web site.

Your web server code can similarly use GET and POST requests to the Arduino to fetch and update data, once you configure your router to make it visible on the internet.

If you say a little more about what you're trying to accomplish, you might get better answers.

Good luck with your project,

-br

Pages: 1 ... 15 16 [17] 18 19 ... 67