Show Posts
Pages: 1 ... 14 15 [16] 17
226  Using Arduino / Programming Questions / "blink without delay" for a function on: February 05, 2012, 08:56:32 am
OK, so I'm trying to play the GMT pips with my Arduino. It works great. Because I'm still waiting for my ethernet shield, I have no way of setting my RTC accurately (the compile delay means it's 15 seconds slow). If there's a way to say
Code:
RTC.adjust(DateTime(__DATE__, __TIME__+15s));
it's news to me ;-)

At the moment I compensate for it in my code. This is OK as an interim solution.

So here's my question:-

Code:
   if (now.second() == 39 && now.minute() == 59)
    {
     digitalWrite(ledPin2, HIGH);
      playTone(100, 2000);
      delay(900);
      playTone(100, 2000);
      delay(900);
      playTone(100, 2000);
      delay(900);
      playTone(100, 2000);
      delay(900);
      playTone(100, 2000);
      delay(900);
      playTone(500, 2000);}
      else

I want to avoid the use of delay, because it means no other LEDs can be lit, no other if statements dealt with, right?

But if I say playTone (900, 0), I just get a very low rumble from my piezo buzzer which brings the loop to a complete halt.

Any tips?

THANKS
227  Using Arduino / Programming Questions / Re: lots of things going on at once home automation on: February 04, 2012, 03:02:41 am
Thanks wildbill.

I guess what I was concerned about was that my project would not be able to have a servo controlling a bell tinkling for 20seconds and then start another ringing at the 10s mark, keep it ringing for 20s, thus finishing to tinkle 10s after the first one.

I have been suitably reassured. :-)
228  Using Arduino / Programming Questions / Re: Greenwich mean time pips on: February 03, 2012, 06:31:54 pm
Code:
int pinSpeaker = 8;

void setup () {
    pinMode(pinSpeaker, OUTPUT);
}

void loop () {
    playTone(100, 1000);
    delay(900);
    playTone(100, 1000);
    delay(900);
    playTone(100, 1000);
    delay(900);
    playTone(100, 1000);
    delay(900);
    playTone(100, 1000);
    delay(900);
    playTone(500, 1000);
    delay(9000);

}

// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

For the benefit of future Googlers who struggled like I did...
229  Using Arduino / Programming Questions / Re: lots of things going on at once home automation on: February 03, 2012, 11:17:14 am
Yes it's perfectly possible. Look at the 'blink without delay' example sketch.

Thanks, I'll do that.
230  Using Arduino / Programming Questions / Re: lots of things going on at once home automation on: February 03, 2012, 11:17:00 am
The code version that I just posted there is single-threaded to suit the problem, but the version I'm using for my own project maintains a schedule queue to handle exactly the kind of multiple process situation you describe.

THIS sounds very useful and a great answer to my question. Thanks. I think you understood what I meant, here.
231  Using Arduino / Programming Questions / Re: lots of things going on at once home automation on: February 03, 2012, 11:16:02 am
It depends on your idea of simultaneous, how many things, how much you want it to do.

Arduino can watch one sensor many 1000 times a second and still have time to act.

I think this is where my understanding of Arduino and thus how I phrase my question leads to me getting this kind of response "the arduino can do X many thousands of times a second". :-)

That's great - so in answer to my question, yes, the Arduino can easily monitor many inputs and control several LEDs doing different things at once.
232  Using Arduino / Programming Questions / lots of things going on at once home automation on: February 03, 2012, 10:23:03 am
I'm planning an Arduino home automation project where I'm going to be monitoring lots of inputs (things like magnetic door sensors, push buttons, temperature sensors, light sensors, the time itself, a PIR etc) and performing certain actions based on their input or state.

How do I program most effectively for this so that multiple events can happen simultaneously?

Like if I want it to be possible for the Arduino to monitor button 1 and when button 1 is pressed servo 1 is activated for 30 seconds.
And WHILST servo 1 is doing its thing, someone presses button 2 and the Arduino concurrently to operating servo 1 activates servo 2 too?

Is it possible to deal with such scenarios? If so, how best?

I've already touched on this in this post - but I'm still not totally convinced I understand...smiley

THANKS
233  Using Arduino / Programming Questions / Greenwich mean time pips on: February 03, 2012, 07:21:30 am
Hi

I was working late last night at a simple buzzer melody. In fact, it's not really a melody because it's just one note. I couldn't find for the life of me how to modify the example code.

I tried everything from adjusting the tempo, to the beats, to the pauses...sometimes I got an infernal loop, sometimes half the 'tune' played - sometimes all of it but incredibly fast! Funny, really.

Is there a generator that will produce the code for the following? I've googled but not found one.

1Khz tone.

0.1s pip.
0.9s pause.
0.1s pip.
0.9s pause.
0.1s pip.
0.9s pause.
0.1s pip.
0.9s pause.
0.1s pip.
0.9s pause.
0.5s pip.

Thanks... maybe it was just late but this didn't seem to be going may way! smiley

The piezo buzzer is a very small one - it's powered to my arduino without any transistor or similar.

If I get a physically larger buzzer does it follow that it'll be louder?

smiley
234  Using Arduino / General Electronics / Which "type" of Arduino starter pack would you buy? on: January 31, 2012, 11:50:28 am
Proto Pic Arduino Starter Kit @ £38

Oomlout Starter Kit @ £57

I'm not so much thinking about components but what would be best for a beginner to learn good practices etc?

Presumably there's a reason the oomlout costs so much more?
235  Using Arduino / Project Guidance / Timed events with Arduino on: January 31, 2012, 07:53:33 am
Starting a new thread because my last thread went dead :-)

I'm looking into buying an Arduino Uno and Ethernet shield. I wanted an Ethermega but can't find a UK stockist. Only an Australian warehouse with a UK style storefront ;-)

I want my Arduino project to do (amongst a lot of other things, like monitoring inputs) to sound a piezo buzzer on the hour every hour from 1800-2200.

I don't want to adjust for daylight savings time.

I read that I can query an internet time server to obtain the current time. I could do this in my sketch every day at 1500, for example. And on power on.

But what I don't know is if I need a RTC module for this to be useful?

Can anyone advise on how this is practically done?

Thanks
236  Using Arduino / Project Guidance / Re: RTC / WWVB / NPL vs ethernet shield on: January 30, 2012, 12:00:23 pm
Looking at this example, looks like the functionality is built in.

The thing I'm unsure about is it says this can be done with or without a time module...

So what's the purpose of the time module? Is that only for non-internet connected projects?

How can I use the time with the above example?

Can I, for example, "get" the time once a day at say 1500, and then have actions configured for 1800, 1900, 2000 and so on?

I'm a little unsure how useful the above example is.
237  Using Arduino / Project Guidance / Re: RTC / WWVB / NPL vs ethernet shield on: January 30, 2012, 09:11:20 am
Hehe, I know I can’t just ask “the internet” what the time is :-)
I can’t even do that from my computer!

But I could poll an NTP server, couldn’t I? Or do as you suggest and use GET on a willing server.

I need the time because I want my arduino project to know what time it is and I don’t want to have to update it when the clocks go forward and back!

So what do you think?

Thanks for your help.
238  Using Arduino / Project Guidance / RTC / WWVB / NPL vs ethernet shield on: January 30, 2012, 07:38:37 am
Hi,

If I have an ethernet shield for my arduino does that mean I don't need to bother with a time module for my project because I can poll the time from the internet?

Or does it mean that I don't nee to bother with a radio module but I very much will still need a RTC module because whilst I can update the time from the interwebs I'll still need a way to keep track of it?

Thanks
239  Using Arduino / General Electronics / Re: switching UK phone extension on: January 13, 2012, 06:26:07 am
I've been having a think. Can someone confirm that using a SPDT relay can be used like a push to break push button, only instead of pushing a button you apply current?

The circuit is closed and working. Current is applied and the relay breaks the circuit because there's nothing connected to the other pins?
240  Using Arduino / General Electronics / Re: switching UK phone extension on: January 11, 2012, 09:49:01 am
Of course. Thank you.
Pages: 1 ... 14 15 [16] 17