Loading...
  Show Posts
Pages: 1 ... 16 17 [18] 19 20 ... 66
256  Using Arduino / Interfacing w/ Software on the Computer / Re: Library for sending/receiving data in UART Linux on: April 11, 2013, 06:40:59 am
Search for "serial communications in C"…  top hit looks potentially useful:

http://www.easysw.com/~mike/serial/serial.html

-br
257  Using Arduino / Programming Questions / Re: rgb led fade on: April 10, 2013, 05:08:44 pm
The trickiness here is using a 16 bit counter (count) to control an eight-bit quantity.  The lowest 8 bits of count are used as the brightness, possibly inverted as I'll get to in a minute.  

The ninth bit of count is used as an up-down indicator, because it rolls over just as you'd like an up-down indicator to: it's off for the first 256 counts, then on for the next 256, and so on.  It's a little state machine, for free.

The expression that is puzzling you (count & 0x100) tests the ninth bit of count to see if it is one or zero (using a bitwise AND between count and a constant denoting the ninth bit).  If the ninth bit is one, we are in the counting down phase, and in that case the code inverts the brighness so instead of going from 0..255 it goes from 255..0, ramping down instead of up.

Read up on bitwise boolean operators for more on & (and) and ~ (bitwise complement) and their friends | (or) and ! (logical complement).

Hope that helps and happy to take followup questions.

-br
258  Using Arduino / Programming Questions / Re: rgb led fade on: April 10, 2013, 04:33:59 pm
Yes, do stop turning off the lights.  And it's not needed to delay between each pin setting.  Something like this should generate the right pattern:

Code:
int count;

void loop() {

// increment the counter and grab 8 bits of brightness
byte brightness = ++count;

// use the next higher bit as an up or down indicator;
// invert the brightness on the down count
if (count & 0x100) brightness = ~brightness;

// update the pwm outputs
analogWrite(R, brightness);
analogWrite(B, brightness);
delay(del);
}
259  Using Arduino / Project Guidance / Re: Need Advice/Help for Starting Project on: April 10, 2013, 12:52:57 pm
Any of the technologies you mentioned could get the job done with varying degrees of work and performance.

I personally find myself following a different route based on pieces I have built.  First you must know that I wrote Bitlash, an interpreter for Arduino, and so I think in terms of sending Bitlash commands from the PC to control things on the Arduino side.  The idea is similar to what TanHadron suggests.  So I usually start with Bitlash on the Arduino side, at least for prototyping. (More at http://bitlash.net)

Then I wrote an app called Bitlash Commander to control the Arduino from the PC by sending commands from a web browser.  This is kind of like the program you will need, to fetch weather data and send it over the serial link.  (More at https://github.com/billroy/bitlash-commander)

Commander is a "node.js" app, written in javascript.  There is a big ecosystem of node.js modules (not unlike perl modules or arduino libraries) that make it easy to drop in big chunks of functionality like reading and parsing web pages. 

If I had to start on your problem today I'd probably work up a little node.js script similar to Commander to do the weather API fetching, parsing, and serial transmission.  Plus a web control panel for the display...

Whatever you're comfortable with, right?

-br
260  Using Arduino / Project Guidance / Re: Need Advice/Help for Starting Project on: April 10, 2013, 12:10:39 pm
Well for starters you need to handle the fact that the Arduino can't see the internet over USB.  You'll need to write a program to run on the PC to do that: handle communications between the Arduino and the internet.

So you will need to choose a PC programming environment.  There are as many opinions about those as there are religions.  Do you have a favorite PC programming environment to start with?  A language where you can find someone locally to help you would be ideal.

The rest of what you have in your wish list is doable, and should make for good fun.  Along the way you should be prepared to learn a bit of web technology (to fetch the weather data) as well as arduino coding and hardware interfacing.

Good luck with your project,

-br
261  Using Arduino / Interfacing w/ Software on the Computer / Re: A fatal error with Arduino and Python on: April 10, 2013, 11:21:33 am
If what you actually want to do is wait for the first '0' from the Arduino, why not:
Code:
    while ser.read() != '0':
        pass

-br
262  Using Arduino / Networking, Protocols, and Devices / Re: different serial baud rates for rx and tx on: April 10, 2013, 10:51:04 am
The hardware serial port operates at one rate for tx and rx.

You could use SoftwareSerial to send data at a different rate using another pin…

-br
263  Using Arduino / Project Guidance / Re: Run other part of sketch every 5 mins.. on: April 10, 2013, 10:35:18 am
A library solution is overkill.  OP needs to lift one if statement from Blink Without Delay.

Dear OP: the form of the solution is in Blink Without Delay, at line 51.

-br
264  Using Arduino / Project Guidance / Re: Run other part of sketch every 5 mins.. on: April 10, 2013, 10:27:50 am
So, you need to add an if statement that checks the time since the last transmission to control when sendData is called:

Code:
   if (…) sendData(capacity);

One implementation of that if statement can be found through a careful reading of Blink Without Delay.

-br

265  Using Arduino / Project Guidance / Re: Run other part of sketch every 5 mins.. on: April 10, 2013, 10:12:50 am
Keep track of the last time you sent a package and don't send another one until five minutes later.

Look at the Blink Without Delay example for code.

-br

266  Using Arduino / Programming Questions / Re: combining two variables to make a new one! to use in DmxSimple on: April 10, 2013, 09:51:05 am
Glad it works.  Good luck with the rest of your project.

-br
267  Using Arduino / Programming Questions / Re: combining two variables to make a new one! to use in DmxSimple on: April 10, 2013, 09:40:43 am
Well, you can do it the roundabout way you suggest, especially if you are being paid by the line.

Or you can use the code I posted up above in Reply #1, which does the same thing without the intermediate conversion to string format.  Take a minute to understand what it's doing.


-br
268  Development / Other Software Development / Re: Contributing to Arduino on: April 10, 2013, 09:37:40 am
Publishing it yourself is the surest way to make it available.

If the code needs to be incorporated into the Arduino core, for example a bug fix or feature enhancement, you can submit a well-formed Git pull request to the core team using the Pull Request tab here: https://github.com/arduino/Arduino


-br
269  Using Arduino / Programming Questions / Re: combining two variables to make a new one! to use in DmxSimple on: April 10, 2013, 09:24:55 am
The routine doesn't like the String argument.

Are you trying to write a string, (or a String?) or a binary integer?

-br
270  Using Arduino / Programming Questions / Re: combining two variables to make a new one! to use in DmxSimple on: April 10, 2013, 09:11:10 am
Code:
zocol = col * 10 + dim;

-br
Pages: 1 ... 16 17 [18] 19 20 ... 66