Show Posts
Pages: [1] 2 3 ... 6
1  Forum 2005-2010 (read only) / Syntax & Programs / Style guide? on: April 18, 2009, 09:38:28 pm
Is there a programming style guide that is either officially or generally used for Arduino sketches? I'm getting pretty far along on my first real project, and I'd like to make the code presentable. I don't have a programming background, but I can tell that I need some guidance.

I searched around but didn't see anything, so I thought I'd ask. About the only formatting I use is the built-in cmd-T Auto Format thing. I haven't been consistent with my function and variable naming, so it leads to my own confusion sometimes.

Thanks!
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: how to do like a grep in a sketch? on: December 05, 2008, 06:05:54 pm
Nice! Thanks dcb, that was the nudge in the right direction I needed.

I got a brute force method to work, later I might work on generalizing it some.

Gordon, I'll watch for your xml reader. That will be super handy for all kinds of things.
3  Forum 2005-2010 (read only) / Syntax & Programs / how to do like a grep in a sketch? on: December 05, 2008, 12:33:11 pm
So I got my ethernet shield just now, and I'd like to try to do something based on what I read from a web page. If I were shell scripting, I'd grep  for the word I'm interested in. How do I do this in a sketch?

To make my question less vague, I've started with the WebClient example sketch, which pulls a query from google. How can I find out if a certain word (say YES or NO) exists on the page?

Thanks!

Below is the example code without modification.

Code:
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 64, 233, 187, 99 }; // Google

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  
  delay(1000);
  
  Serial.println("connecting...");
  
  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}

4  Forum 2005-2010 (read only) / Interfacing / Re: Ehternet shield on: December 19, 2008, 03:14:12 pm
Did anyone else laugh out loud for real when they saw the MAC in the sample code?

(I'll save everyone the trouble, it's DE:AD:BE:EF:FE:ED.)
5  Forum 2005-2010 (read only) / Development / Re: Problem with multpile (fast) client-requests (Eth) on: February 24, 2009, 02:59:26 pm
I've been having a similar problem, but not related to the speed of requests.

I have mine set up to pull a web page every 60 sec, and I have an LED indicate when there was a connection failure. Maybe I should log the failures so I know for sure how often they happen, but it seems to have a fair number of them throughout the day.

The server is of course up and responding, but I'm not sure what to look at in my Arduino to see what the problem is.
6  Forum 2005-2010 (read only) / Development / Re: Pin clocks on: December 08, 2008, 04:01:34 pm
I received one of these clocks as a gift a while back. First off, there are no pins in this clock; it's designed to look like there are though. I'll try to describe it.

Behind the clear cover there is a main background with bumps that look like pin heads. The board and pins are the same color grey plastic, since it is just one molded piece of plastic.

Also on the main background there are areas with holes for the "pins" that do move, laid out in a pattern like a 7-segment LED display. Each segment moves in and out (matching those fixed bumps or raised) of the holes to display that segment's "pins."

I say "pins" because it's really just another piece of that grey plastic but shaped like the segment and with taller bumps that appear to be pins.

I haven't had it running in quite a while since it's noisy enough to bug my wife, so this is from memory. On the minute, each segment gets reset to the correct position in sequence (with much clatter, leading to the shutting off mentioned above). It does it this way because the segments aren't ever held in place, they only get toggled in or out. If you lay the clock on its back, the raised segments will fall back down immediately so the display is blank. You can lay it on its face and the opposite will happen.

I have never taken it apart to see what kind of solenoid or motor arrangement is in there, but I believe each digit is generated by pulling/pushing on the segments in order, not all at once.
7  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Interesting Observation on Analog Input on: December 16, 2008, 03:04:54 pm
I believe you need to use the analog input pin numbers when you use analogRead(). And you don't need to set the pin mode.

http://www.arduino.cc/en/Tutorial/AnalogInput
8  Forum 2005-2010 (read only) / Interfacing / Re: Ethernet Shield IP & Mac Address problems on: March 25, 2009, 10:36:36 pm
I started with the sample sketches, and only changed the IP address. You can't use an address that is already in use on your network, which includes your computers and router. Try to ping* an address that's one number different at the end than your router address. (That is, if your router is 192.168.1.1, try 192.168.1.2.) If ping doesn't return any responses, you can use that address. If it does show a response, try the next one.

* From a command prompt, just type ping 192.168.1.2<enter> , for example.
9  Forum 2005-2010 (read only) / Interfacing / Re: LDR Troubles... on: December 15, 2008, 02:26:54 pm
Wouldn't you use ldr = 0 instead of 14 to refer to analog input pin 0?

(Cf. http://www.arduino.cc/en/Tutorial/AnalogInput )
10  Forum 2005-2010 (read only) / Interfacing / Re: arduino to dial telephone? on: August 03, 2008, 08:18:56 pm
I should give some more info, I think. I'm trying to adapt an old-timey crank phone for modern use. My idea is to count the number of cranks of the handle and make that dial one digit. There is a switch in there that is thrown when you apply pressure to the crank, so I could use that to start/end counting. I'm not sure if there is anything in it to count the number of turns but there is a nice big gear that could hold a few magnets to use a hall effect sensor.

I like the idea of the modem, because it would take care of a lot of the problem and I have a few of those laying around. All I'd need to do in code is build the number to be dialed, and then issue the atdt command over serial to it. I'll also have to make it not try to handshake. I'm sure there's a command for that. Hardware-wise, I would need to connect to that crank switch, do the serial cable to the modem, and the crank handle revolution counter.

The nice thing about this particular phone is that it had been converted to a rotary dial, so it has been re-wired to a state that I can probably plug it in to the phone jack on the modem.

Thanks for the ideas!
11  Forum 2005-2010 (read only) / Interfacing / arduino to dial telephone? on: August 02, 2008, 07:21:13 pm
I have a project in mind that would dial a phone number on a POTS phone. Assuming I can generate dtmf dialing tones (perhaps even with a wave shield using downloaded tones if necessary) what do I need to be aware of in terms of connecting to a phone line? I'm sure there's voltage levels to be concerned with, but I'm not sure where to start looking or what to do to protect the arduino.

For the purposes of the project, I don't need to lift the receiver within the arduino; that will be done physically by the caller.

I'm still a relative beginner with this, so please excuse me if I'm missing something obvious.

Thanks!

12  Forum 2005-2010 (read only) / Workshops / Re: St. Louis MO - Workshop/advice on: September 08, 2008, 04:10:10 pm
I'd be interested in participating, but I don't have any advice.
13  Forum 2005-2010 (read only) / Exhibition / Re: LumiNet (based on attiny84) on: March 07, 2009, 12:11:29 pm
Interested in more info! Very cool.
14  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pro Mini Glowstaff on: January 16, 2009, 04:21:59 pm
Neat!

Are you sure it doesn't need fire?  smiley
15  Forum 2005-2010 (read only) / Exhibition / Re: Arduino driven Nixie Clock on: February 24, 2009, 02:52:45 pm
Awesome! I love nixies. Some day I'll have some of my own, and I'd love to build my own clock like this.
Pages: [1] 2 3 ... 6