Show Posts
Pages: 1 ... 425 426 [427] 428 429 ... 584
6391  Using Arduino / Programming Questions / Re: How to extract server/domain from a URL in char[] on: July 02, 2011, 08:53:16 am
I would start by getting any possible "http://" out of the way, something like

Code:
string_index = 0;  // assume there's no http://

if (memcmp ( "http://", requestedURL, 7) == 0)
    string_index = 7;

// now we can start with a clean string
// do stuff starting at requestedURL[string_index];

______
Rob
6392  Using Arduino / Programming Questions / Re: sei() and cli() inside interupt service routines on: July 02, 2011, 08:44:27 am
As far as I can tell the cli() does absolutely nothing as interrupts are disabled anyway in the ISR.

The sei() may have an affect in that it allows any pending interrupts to happen before this one has quite finished. However why that would be a good idea escapes me.

_____
Rob
6393  Using Arduino / Installation & Troubleshooting / Re: button on digital pin 0 and 1, pin 0 stay's high...? on: July 02, 2011, 08:37:54 am
One difference between the two pins is that 0 is driven high by the FTDI chip (through a resistor) and 1 is not. We need to see a schematic.

But why are you using pins 0 and 1 at all? It's bound to cause you trouble.

Just use two other pins.

______
Rob
6394  Using Arduino / Programming Questions / Re: pin change interrupt on: July 02, 2011, 08:30:03 am
Quote
in the interrupt i will call GetKey function
Normally this (the GetKey function) is way too long to be called from an ISR, especially with that delay(10) there.

if(KeyVal == ReadSensor(1))

What does ReadSensor() read from? If it's an analogue input there's a 1 in 1024 chance it will be == KeyVal, meaning that the following code in the if block will probably never be executed.

I would have the ISR and code more like

Code:
volatile int sensor_val;

ISR (TMR1_OVL_vect) { // I forget the actual timer vector name but you cannot use a PCINT_vect
   sensor_val = ReadSensor(1);
}

loop () {
  if (sensor_val > 856) ... etc etc
}


______
Rob
 
6395  Using Arduino / Programming Questions / Re: Understanding serial data on: July 02, 2011, 07:02:18 am
strcmp() is for comparing two strings, meaning a NULL-terminated series of chars.

You are trying to compare a byte (ReOn) with a string ("redon") and the compiler doesn't like it.

How on earth this

byte ReOn = 'redon';   
byte ReOff = 'redoff';
byte GrOn = 'greenon';
byte GrOff = 'greenoff';

even compiles I have no idea, but it's not valid code AFAIK.

If you want to use strings then declare them like this

char ReOn[] = "redon";


______
Rob



6396  Using Arduino / Project Guidance / Re: Arduino Relays for Failsafes on: July 02, 2011, 05:43:43 am
MAX791
MAX6316/17/18/19/20/21
TPS3600

Should get you started.

Google something like "microprocessor supervisor"

Also look at circuits for a 555 timer in "monostable" mode (I haven't used a 555 for decades but I think it will hold its output low/high as long as it gets trigger pulses).

Another option is to use an ATtiny85 with your own 5-line program (well maybe 10 lines smiley) to do the same thing.

______
Rob
6397  Using Arduino / Project Guidance / Re: Arduino Relays for Failsafes on: July 02, 2011, 04:13:30 am
Quote
if I just came along and smashed the Arduino with a hammer
There are several "supervisor" chips that expect a pulse from the processor and will act if it doesn't appear for a while.

A simple 555 timer can be wired to do the same thing.

______
Rob

6398  Using Arduino / Interfacing w/ Software on the Computer / Re: Another Arduino VB Serial question. on: July 02, 2011, 04:09:09 am
Here's some VS 2008 code I've used before
Code:
Public Class Form1
    Dim stop_serial As Boolean = False


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        Dim last_i As Integer = 255
        TextBox1.Clear()
        Do
            Try
                i = SerialPort1.ReadByte()
                If i <> last_i Then
                    TextBox1.Text = TextBox1.Text + Str(i) + "  " + Now + vbCrLf
                    TextBox1.Refresh()
                    last_i = i
                End If
            Catch ex As Exception
            End Try
            Application.DoEvents()
        Loop While Not stop_serial

    End Sub

    Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        If SerialPort1.IsOpen() Then
            SerialPort1.Close()
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.PortName = "Com39"
        SerialPort1.ReadTimeout = 10

        SerialPort1.Open()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        stop_serial = True
    End Sub
End Class

The DoEvents allows Button2's click to be read which in turn allows the main loop to exit. Using a timeout also stops the serial call from hanging.
______
Rob

6399  Using Arduino / Programming Questions / Re: Understanding serial data on: July 02, 2011, 03:46:03 am
That screen shot implies to me that the iphone is sending a CRLF after each string, ie "redonCRLF".

Try doing

Serial.println (inbyte, HEX)

to see exactly what is being sent (post the results)

You can use those funcs in an if() statement

if (strcmp (string1, string2) == 0) ... // the strings are equal

Whether or not that's the right way to handle your program is another matter. I'd be inclined to send a single character, say

r = red off
R = red on
g - green off
G = green on

Then your (slightly modified) switch statement will work (all other characters such as CR and LF will be ignored).

______
Rob

6400  Using Arduino / Programming Questions / Re: Understanding serial data on: July 02, 2011, 02:15:57 am
Quote
is it possible to compare to an array of bytes
Have a look at the strcmp() and memcmp() functions.

But you can't use them directly in a case statement.

______
Rob
6401  Using Arduino / Microcontrollers / Re: Freetronics Eleven vs Genuine Arduino on: July 01, 2011, 12:43:10 am
I have a Freetronics 2010 and it's just fine. Never done anything it shouldn't and always done what it should smiley

Most of the Arduino boards around are clones, I wouldn't worry about it especially from a well-known supplier (which Freetronics are).
______
Rob
6402  Using Arduino / LEDs and Multiplexing / Re: Shift Registers on: June 25, 2011, 07:05:44 pm
Your DoLED func will output 9 pulses, one for every bit and another for the "Position" bit. Try
Code:
void DoLED(){
 
   digitalWrite(latch, LOW);   
     
   for(int i = 0; i < 8; i++){             
if (i == Position)                     
  digitalWrite(data, HIGH);
else
  digitalWrite(data, LOW);

  digitalWrite(clock, HIGH);               
  digitalWrite(clock, LOW);

}
 
digitalWrite(latch, HIGH); 

}

______
Rob

6403  Using Arduino / Displays / Re: 4D LABS μLCD-32PT(SGC) 3.2” Serial LCD Display Module Arduino Library on: June 24, 2011, 02:48:24 am
Lookin' good, I'm still nowhere near using my displays yet but am paying attention smiley

______
Rob
6404  Using Arduino / Programming Questions / Re: Indenting & Formatting Styles - which do you use? on: June 24, 2011, 02:17:08 am
I vote for what I guess is the K&R style. I probably like it because I started with the K&R book many years ago. Also I used to work for a company that enforced strict K&R "syntax" (if that's the right word) with no fancy new libraries or features.

______
Rob
6405  General Category / General Discussion / Re: Examples of commercial use? on: June 24, 2011, 02:06:28 am
These guys

http://arduino.cc/forum/index.php/topic,61490.0.html

Look like they plan to use Arduinos, but I think it's just for test rigs not production gadgets.

______
Rob
Pages: 1 ... 425 426 [427] 428 429 ... 584