Show Posts
Pages: 1 [2] 3 4 ... 33
16  Forum 2005-2010 (read only) / Troubleshooting / Re: how do I extract code from an Arduino? on: February 04, 2010, 02:23:40 pm
Mac OS X and its Time Machine thingy?

Andrew
17  Forum 2005-2010 (read only) / Troubleshooting / Re: The Icehockey Feed on: January 27, 2010, 05:34:29 am
I faced a similar problem when I wanted to get the Arduino to display weather information - having it scrape a weather forecast web site and do the parsing itself seemed a bit daunting. What I did is put an intermediary PHP script on a webserver, have the Arduino request that script instead and that script grabbed the weather forecast page and did some parsing in order to return a simple string to the Arduino. The PHP script used a library called simple_html_dom (http://simplehtmldom.sourceforge.net/ ) in order to parse the weather forecast page, and was very simple to write. Here's the PHP code:

Code:
<?php
include_once('simple_html_dom.php');

// create HTML DOM
$html file_get_html('http://news.bbc.co.uk/weather/forecast/2201?printco=Next12Hours&temp=centigrade');

$timeblocks $html->find('div[class=times]'0);
$timeblock $timeblocks->find('div[class=time]');

foreach(
$timeblock as $block) &#123;
      
echo trim($block->find('h3'0)->plaintext);                // time
      
echo " ";
      echo 
trim($block->find('img'0)->alt);                     // forecast
      
echo " ";
      echo 
trim(str_replace("&deg;""." $block->find('span[class=cent]'0)->plaintext));  // temp
      
echo " -- ";
&
#125;
 
   
// clean up memory
$html->clear();
unset(
$html);

?>

Hope this gives you some ideas.

Andrew

PS The weather scraping script has now stopped working as the BBC changed their weather forecast pages. That's the trouble with scraping - it's very brittle.
18  Forum 2005-2010 (read only) / Troubleshooting / Re: Help needed: direct drive LED matrix on: April 02, 2009, 04:28:40 am
Back when I wrote this code people were asking about it so I produced a commented version. Hopefully this will help you figure out what to do (also you can see the original thread at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203747843/17#17).

Code:
void slidePattern(int pattern, int del) {
  // Loop 8 times, once for each column of new character to scroll in
  for (int loop = 0; loop < 8; loop++) {
    // First shuffle existing columns 1 to 7 into cols 0 to 6
    for (int i = 0; i < 7; i++) {
      // Do each row of each column
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    // Now copy new column from pattern onto end column of display
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + loop];
    }
    // Wait for a bit
    delay(del);
  } // end loop for each column of new pattern
} // end function

Andrew
19  Forum 2005-2010 (read only) / Troubleshooting / Re: Resources for Learning C with Arduino on: September 14, 2009, 04:32:14 am
Quote
@Mike Mc
That's a great find!

He didn't find it, he wrote it...

Andrew
20  Forum 2005-2010 (read only) / Troubleshooting / Re: stupid question.. on: August 31, 2009, 06:12:47 am
If you managed to compile it, then (on Windows at least) it creates a temporary folder with all the files. It would be somewhere like this:

Code:
C:\Documents and Settings\<<user name>>\Local Settings\Temp\untitled2736.tmp\sketch_aug31c

So it might be worth looking in your temp folders to see if it's still there.

Andrew
21  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem uploading to 328p on: August 09, 2009, 11:32:45 am
Sorry, I should have spelled out the details a bit more. I hesitated to make the suggestion at all actually as I thought you'd probably know about stuff like that already if you were doing advanced things like building and uploading from the command line. Glad you got it working.

Andrew
22  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem uploading to 328p on: August 08, 2009, 09:51:04 am
If the 328 works when you program it from the IDE, can you not set upload.verbose=true in the preferences.txt file and see what avrdude command the IDE uses? The same thing should then work from the command line.

Andrew
23  Forum 2005-2010 (read only) / Troubleshooting / Re: Weather Report. on: May 18, 2009, 08:47:35 am
Unless I'm mistaken you can't get the BBC's next 12 hours forecast as an RSS feed, and that's the one I wanted.

Andrew
24  Forum 2005-2010 (read only) / Troubleshooting / Re: Weather Report. on: May 15, 2009, 02:16:50 pm
This (weather forecast on web -> Arduino -> some kind of display) is actually yet another thing on my list of things I'm going to do one day "when I get around to it" so I thought I'd pass on what I was thinking in case you find it useful.

I was planning to use an ethernet shield and get the Arduino to fetch the weather forecast data itself over the network. In preparation for this I looked at "scraping" the info off the BBC's horrible new weather forecast pages and transforming it on a server to a simpler string that the Arduino could read direct to offload the heavy duty processing. I discovered a PHP library called "simple_html_dom" that lets you parse and manipulate html and made a page on my server that returns the bare bones of the forecast.

The PHP on my webserver is as follows:

Code:
<?php
include_once('simple_html_dom.php');

// create HTML DOM
$html file_get_html('http://news.bbc.co.uk/weather/forecast/2201?printco=Next12Hours&temp=centigrade');

$timeblocks $html->find('div[class=times]'0);
$timeblock $timeblocks->find('div[class=time]');

foreach(
$timeblock as $block) &#123;
      
echo trim($block->find('h3'0)->plaintext);                // time
      
echo " ";
      echo 
trim($block->find('img'0)->alt);                     // forecast
      
echo " ";
      echo 
trim(str_replace("&deg;""." $block->find('span[class=cent]'0)->plaintext));  // temp
      
echo " -- ";
&
#125;
 
   
// clean up memory
$html->clear();
unset(
$html);

?>

and it turns the complicated HTML of the weather page into a string like this:
Code:
19:00 Sunny Intervals 13.C -- 22:00 Light Rain Shower 11.C -- 01:00 (Sat) Light Rain Shower 9.C -- 04:00 (Sat) White Cloud 7.C --

The Arduino could easily read that string and send it direct to an LCD or LED display, or you could say just use the forecast temperature and control one of those LED bargraph things you used to get on Hi-Fi's. Or make a retro display with an analogue gauge or two, maybe one for temperature and another one that points to sunny, cloudy, rainy etc. using servos.

Anyway, just some ideas I had before I got distracted by the next cool thing I was going to do...

Andrew

25  Forum 2005-2010 (read only) / Troubleshooting / Re: Weather Report. on: May 15, 2009, 09:58:06 am
I interpreted the original proposal as downloading a weather forecast from a website and showing it on (for instance) an LCD attached to the Arduino.

Who's closest?  smiley

Andrew
26  Forum 2005-2010 (read only) / Troubleshooting / Re: Simple coding question for painfully new user on: May 26, 2009, 05:38:45 am
Well, that's not quite what I was thinking of but well done for getting it working. I had in mind something like this (this isn't necessarily actual working code, just a rough outline):

Code:
int MODE_OFF=0;
int MODE_ON=1;
int MODE_BLINKING=2;
int value = LOW;
long previousMillis = 0;
long interval = 250;
int mode;

setup() {
  mode=MODE_OFF;
}

loop() {
 val1 = digitalRead(btnPin1);
 val2 = digitalRead(btnPin2);
 val3 = digitalRead(btnPin3);
 if (val1 == LOW) {
   mode = MODE_OFF;
 }
 else if (val2 == LOW) {
   mode = MODE_ON;
 }
 else if (val3 == LOW) {
   mode = MODE_BLINKING;
 }

 switch (mode) {
   case MODE_OFF:
     digitalWrite(ledPin, LOW);
     break;
 
   case MODE_ON:
     digitalWrite(ledPin, HIGH);
     break;

   case MODE_BLINKING:
     if (millis() - previousMillis > interval) {
       previousMillis = millis();
       if (value == LOW)
         value = HIGH;
       else
         value = LOW;
       digitalWrite(ledPin, value);
     }
 }

}


then you can convert it to use just one button easily. Each time the button is pushed, set "mode" to the next value, wrapping around from blinking to off. You'll probably then need to use debouncing on your switch or it could advance several modes on each push; see http://arduino.cc/en/Tutorial/Debounce for an introduction and here http://www.arduino.cc/playground/Main/InterfacingWithHardware#Switches for some more advanced stuff to help you debounce switches.

Finally the code as above is a bit inelegant - each time around the loop it does a digitalWrite to the pin even if the mode hasn't changed e.g. it's still OFF or still ON. You could modify it to only do the digitalWrite if the mode has changed from off to on or vice versa, but elegance and efficiency come after getting something working.

Andrew
27  Forum 2005-2010 (read only) / Troubleshooting / Re: Simple coding question for painfully new user on: May 21, 2009, 02:22:57 pm
You need a variable that holds what "mode" the light is in, say 0 for off, 1 for on and 2 for blinking. Then button presses change the contents of your mode variable, and each time round the loop you check what the mode is and do stuff to the LED accordingly. You'll definitely want to read up on blinking an LED without using delay (hint - "BlinkWithoutDelay").

Andrew
28  Forum 2005-2010 (read only) / Troubleshooting / Re: Simple coding question for painfully new user on: May 21, 2009, 10:58:30 am
You're not updating the value of val3 inside your while loop so once it gets in that loop it stays there as val3 can never change again.  So the simplest solution is to put "val3 = digitalRead(btnPin3);" inside your while loop. You'll probably notice once you get that working that it's only checking whether button 3 is down once every half a second, so your next challenge will be to rewrite your while loop without using delay().

Andrew
29  Forum 2005-2010 (read only) / Troubleshooting / Re: Acer Aspire One? on: January 09, 2009, 07:47:21 am
You might find our experiences with the Asus EEE PC interesting - threads here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1200721730 and here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1197051207

Andrew
30  Forum 2005-2010 (read only) / Troubleshooting / Re: Confused: I'm running two sketches at once. on: May 09, 2009, 02:01:15 pm
I don't own one but as I understand it the touchshield is another Arduino, just one with a display built in. So you can run a program on it as you've discovered. I think the idea was you run a sketch on the slide that deals with getting input and generating displays, and it talks to your main program on another Arduino to do any processing required.

Andrew
Pages: 1 [2] 3 4 ... 33