NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » C Code to Interact with the Controller

February 01, 2011
by kvjohnso
kvjohnso's Avatar

Does any have any C examples of reading the temp sensor from the computer versus, or in conjunction with, the LCD; basically a program to interact with the controller?

Thanks,

Ken

February 01, 2011
by Ralphxyz
Ralphxyz's Avatar

Well starting with the tempsensor project we have:

  // start up the serial port
  uart_init();
  FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
  stdin = stdout = &uart_stream;

Lines 75 -78

and then:

    // write message to serial port
    printf_P(PSTR("%.2f degrees F\r\n"), temp_avg);

Line 110

So this gets you talking with your PC. If you open a Terminal program and connect to the com port you will get the temperature readout on you PC.

Now if you want to have a program process the temperature data Google "serial data capture" you will gets hundreds of examples including scripts to send your data to a Excel spread sheet.

And then of course there is Python which the Nerdkits guys use (and a whole lot other people as well). Most of the Nerdkits tutorials have python routines capturing the serial data you can modify these scripts to get what you want.

There is also a ongoing discusion here in the forum on using Visual Basic and/or C++. Ask on this thread for more specifics about using VB or C++.

Ralph

February 03, 2011
by kvjohnso
kvjohnso's Avatar

Hey! Thanks for the reply. I guess I missed that printf statement :(. I was able to write a quick Perl script to monitor the /dev com. I like Perl better because it's more mature and there is a lot more modules (CPAN) out there for cool things like this ( my opinion of course :) ).

Thanks again Ralph.

Ken

Post a Reply

Please log in to post a reply.

Did you know that NerdKits make a great parent/child activity? Learn more...