Show Posts
Pages: 1 ... 60 61 [62] 63 64 ... 85
916  Using Arduino / Programming Questions / Re: For loops?? on: December 03, 2012, 04:29:53 am
You are changing the 'Board' to be the 85, right? You cannot just load Uno or other code into the 85 without selecting the right libraries.

In principle there is nothing in the code that assumes a specific processor and no direct to hardware code or oher tricks are used. What can change is the speed of the processor (MHz) and how the libraries are constructed for the new device.

When I compile my version for the Uno I get
Binary sketch size: 1,436 bytes (of a 32,256 byte maximum)

If I select the 85 my IDE will not even comple the code, and I see from the datasheet that it only has 512bytes of SRAM, so the code may not even fit if it could get it to compile.
917  Using Arduino / Programming Questions / Re: For loops?? on: November 30, 2012, 07:54:38 pm
Here is the explanation:
* MB_HIGH and MB_LOW are pretty obvious. They keep the LED on or off for the specified time.
* MB_LOOP makes the pattern loop back to the nominated array element in the pattern for the specificed number of times.

So the data
 { 3, 0, 0, {{MB_HIGH, 25, 0}, {MB_LOW, 25, 0}, {MB_LOOP, 3, 0}, {MB_LOW, 300, 0}}, 0 },
does this:
0 LED on for 25 ms
1 LED off for 25 ms
2 Loop back to element 0 and repeat it 2 more time (3 total)
3 LED off for 300 ms - this is just a delay while the 'other' LED does its thing

So if we want to have a paired LED that works in tandem with this one we need to have the logic
0 LED off for 300 ms - this is just a delay while the 'other' LED does its thing
1 LED on for 25 ms
2 LED off for 25 ms
3 Loop back to element 1 and repeat it 2 more time (3 total)

which provides to table entry
 { 4, 0, 0, {{MB_LOW, 300, 0}, {MB_HIGH, 25, 0}, {MB_LOW, 25, 0}, {MB_LOOP, 3, 1}}, 0 },

So if we look at them as a pair:
 { 3, 0, 0, {{MB_HIGH, 25, 0}, {MB_LOW, 25, 0}, {MB_LOOP, 3, 0}, {MB_LOW, 300, 0}}, 0 },
  { 4, 0, 0, {{MB_LOW, 300, 0}, {MB_HIGH, 25, 0}, {MB_LOW, 25, 0}, {MB_LOOP, 3, 1}}, 0 },

You can see that the second MB_LOOP (pin 4) is in a different spot in the sequence and it loops back to a different place in the array. That is because we need to add the initial delay to the second LED while the sequence for pin 3 is executing.

918  Using Arduino / General Electronics / Re: Desoldering a potentiometer on: November 25, 2012, 05:53:18 pm
The biggest problem with desoldering things this big is the amount of heat needed to do the job. Make sure your iron is hot hot and that you focus on one connection at a time, get it really nice and hot to make sure that all the solder is melted and then a solder sucker will be able to clear the hole well enough.

Reducing the amount of metal that needs to be heated up always helps, so cut off the pins as low as possible from the solder side.

You will find the big lugs are the hardest to get clear as they are probably connected to the ground plane on the PCB and you will be heating up a lot of the board in doing the job. Maybe a combination of heat gun for the board and soldering iron to heat up the connection?

Another approach - you may want to sacrifice the pot (which actually looks like a rotary encoder) and get another. That give you the option to snip it off from the component side. smiley
919  Using Arduino / Programming Questions / Re: break the while loop with boolean on: November 24, 2012, 04:36:33 pm
    else if (buttonState == LOW);

By putting a semi-colon after the if statement here you have created an empty if clause (ie, no action), so nothing happens.

Just as a tip - you don't have to test with an if in the else part of the statement - else is already everything else so if it not == HIGH everything else (in this case == LOW) will flow into the else without the special test.

And here is also an alternative for your code:
void loop()

  boolean change = false;
  digitalWrite(LED1, LOW);
  while (change == false)
    buttonState = digitalRead(buttonPin);
    if (buttonState == HIGH)
      digitalWrite(LED1, HIGH);
      delay (2000);
    change = (buttonState == HIGH);
920  Using Arduino / Project Guidance / Re: Controlling 240VAC outlets based on a master outlet being energised on: November 22, 2012, 05:01:03 am
The idea is that the saw is plugged in and activated with a remote switch on the saw handle. The other devices are separately plugged in and turned 'on' but not operating because there is no power at their outlet. Once the saw is turned on, this is detected and power allowed to flow through to the other devices.

Your wire idea may work ok. Does this need to be around one of the AC wires (ie just the Active line)or will it work ok wrapped around the entire cable, which in my case will be earth, neutral and active?
921  Using Arduino / Project Guidance / Controlling 240VAC outlets based on a master outlet being energised on: November 22, 2012, 03:27:30 am
Hi all,

I have have circular saw used for woodworking and I want to be able to turn a number of other AC outlets on when the saw is in use (eg, fan, vacuum for sawdust, etc). Does anyone know of an existing implementation of this idea?

If not, it looks like a CT (Current Transformer) is the most obvious way to detect that the master outlet (circular saw) is operating. Any other less obvious, and possible less expensive, ideas as a sensor for doing this?

Once the current has been detected turning on a relay to power the other outlets is easy ...
922  Using Arduino / Programming Questions / Re: Need to stop my function on: November 21, 2012, 01:47:53 am
You need to eliminate the delays from your code. These stop anything else from happening while they are active.

Look at the Blink without delays example on how to use the millis() function to determine what time has passed each time through the loop. You will need to remember what you were doing at each stage so that you can pick it up the next time through (look up Finite State Machine).
923  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: November 20, 2012, 07:22:57 am
You should have plenty of processing power to do everything you need. Initially make sure that you have no delay() or waiting timeouts in the code. This is usually the killer for most new programmers as even 1 millisecond repeated in a loop can cause a big delay. Eliminate these by implementing Finite State Machine techniques.

What else you can do depends on what your priorities are. If the LEDs are secondary priority to the IR then putting up with a slightly irregular pattern may be easiest.

Look at interrupt routines to receive and send the IR characters. I use an IR library (IRRemote) that does not cause me delays If nothing else you may want to see how this person has implemented his code.
924  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: November 17, 2012, 02:09:46 pm
This is probably your problem

z = pulseIn(A0, HIGH, 20000);

The last value is the timeout in microseconds. From the online reference:

timeout (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long)

20k microseconds is 20 milliseconds. This is like putting a delay() of 20 milliseconds every time through the loop. Some of the patterns are only on/off for that amount of time, so you would see interference.

I would suggest making this much smaller. Experiment as to where the limit is by putting in a call to delayMicroseconds() instead of pulseIn() and play with the values until you find one that provides acceptable response. This will probably have to be a small fraction of the time that the fastest pattern executes.
925  Using Arduino / Programming Questions / Re: optimizing code: help avoiding modulus.. on: November 17, 2012, 02:26:56 am
Depending on the relative sizes of the numbers, subtracting pitch from conta until it is less than conta gives you the remainder if it was divided (modulus). This can be done in a very tight loop and if the numbers are close only a few subtractions are necessary.
926  Using Arduino / Sensors / Re: N00b: pausing a loop on: November 16, 2012, 01:05:29 am
Look at the blink without delay example.

This is the same except instead of blinking a LED you don't want to move the servo for a set time. The technique of using millis() is identical.
927  Using Arduino / Programming Questions / Re: How to escape while control structure with implement of switch case on: November 13, 2012, 05:31:12 am
Oops! You need to have an else that saves the key to oldkey if the key is valid. This remembers it for next time.
928  Using Arduino / Programming Questions / Re: How to escape while control structure with implement of switch case on: November 13, 2012, 04:52:33 am
This may work as well

void loop()
  static char oldkey;
  char key = kpd.getKey();

  if (!key)  // Check for a valid key.
     key = oldkey;


/* -------- This code not needed if all we want is to print the key

    switch (key)
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
      case '8':
      case '9':
      case '*':
      case '0':
      case '#':
 ---------------- */
929  Using Arduino / Audio / Re: Sending a Midi Note on: November 05, 2012, 05:25:26 am
It turns on an internal pull down resistor when used that way.
930  Using Arduino / Programming Questions / Re: Reading off a Bouncing Push Button on: November 04, 2012, 04:41:40 am
Do you need to use an interrupt at all? If you consider that in the time you press a button the CPU can execute hundreds of thousands of instructions, can you use this speed to adopt a polling mechanism instead, using the techniques shown in blink without delay?
Pages: 1 ... 60 61 [62] 63 64 ... 85