Loading...
  Show Posts
Pages: 1 ... 28 29 [30] 31 32 ... 48
436  Using Arduino / General Electronics / Re: Question about Leds and Resistors on: September 04, 2012, 06:32:18 pm
One resistor per LED will control the exact same current going through the LED, hence brightness will be the same when they are all on. One or more make no difference here.

Sharing one or more LEDS per resistor will make them less bright IF they are on at the same time.

It is basic electric circuit theory - serial and parallel circuits and the current that flows through the parts of the circuit.

I am not sure I understand what you mean by more than one resistor - on one LED or for each LED?
437  Using Arduino / LEDs and Multiplexing / Re: Problem with binary and shift register on: September 04, 2012, 06:29:18 pm
You should just use the logical bit functions. So you can either use the form (1<<n) - one shifted right by n positions - or the bit set/reset functions that are defined in the Arduino header file. Personally I usually use the shifting functions. Pow() will pull in the floating point functions and is rather slow.

Look at bit shft operands <<, >> in any C or C++ manual
438  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: September 04, 2012, 06:24:55 pm
Put it either at the start of loop or at the end of loop.
439  Using Arduino / LEDs and Multiplexing / Re: Led Strobe Lights (Multi Patterns) Help on: September 04, 2012, 05:59:55 pm
This should do the same thing without blocking. I have not compiled or tested this code, so there could be some errors.

This function could be added anywhere to give the fading as it is self contained.

Code:
#define FADE_IN 0
#define FULL_BRIGHT 1
#define FADE_OUT 2

#define FADE_DELAY 45 //ms
#define FULL_DELAY 70 //ms

#define LED_PIN 5
#define FADE_MAX 30 // max PWM value
#define FADE_MIN 1

void Beacon()
{
  static uint32_t nextWakeup = 0;
  static uint8_t currentState = FADE_IN;
  static uint8_t fadeValue = FADE_MIN;

  if (millis() <= nextWakeup)
    return;  // do nothing as time has not expired

  switch (currentState)
  {
    case FADE_IN:
      analogWrite(LED_PIN, fadeValue++);
      if (fadeValue >= FADE_MAX)
      {
        currentState = FULL_BRIGHT;
        fadeValue = FADE_MAX;
      }
      nextWakeup = millis() + FADE_DELAY;
    break;

    case FULL_BRIGHT:
      digitalWrite(LED_PIN, HIGH);
      currentState = FADE_OUT;
      nextWakeup = millis() + FULL_DELAY;
    break;

    case FADE_OUT:
      analogWrite(LED_PIN, fadeValue--);
      if (fadeValue <= FADE_MIN)
      {
        currentState = FADE_IN;
fadeValue = FADE_MIN;
      }
      nextWakeup = millis() + FADE_DELAY;
    break;

    default: // error catch all - restart the sequence
      currentState = FADE_IN;
      fadeValue = FADE_MIN;
    break;
  }

  return;
}
440  Using Arduino / Sensors / Re: Weird reading with LM335 on: September 04, 2012, 04:58:04 pm
This sensor is very sensitive to the voltage and you may have a voltage drop on the line.

Most calculations assume a steady 5V and the change in voltage is proportional to that full range. If the voltage is 4.5 or 5.5 a very large error can be induced in the calculated value.

Have you checked the voiltage at the remote sensor? You may find adding a small capacitor across the power supply near the remote sensor will help (stores charge and helps to even out V fluctuations)..
441  Using Arduino / General Electronics / Re: Question about Leds and Resistors on: September 04, 2012, 04:52:09 pm
If you use one resistor you will be ok. The point is that the resistor setes the maximum current that is allowed to flow in the circuit. If onlky one LED at a time is on then you will get the same light intensity from each LED. If you ever want to change to use more then on e LED then you will find the current will be shared between the LEDs (parallel circuit) and the LEDs will be correspondingly dimmer.
442  Using Arduino / Sensors / Re: Noise on my inputs. on: September 03, 2012, 08:47:27 pm
You should also consider putting capacitors across the motor terminals to absorb any spikes. Lots of literature on this if you Google it.
443  Using Arduino / Sensors / Re: Ultrasonic senor working in flashes on: September 02, 2012, 10:26:04 pm
Have you tried using one of the libraries avilable for the device to see if it still happens? When you do get readings, are they correct (is 10cm really 10cm)?

There is a big thread in this section for a library (now at version 1.5 I think) that works very well - http://arduino.cc/forum/index.php/topic,106043.0.html
444  Using Arduino / Sensors / Re: Simple magnetic contact switch is not working right. on: September 02, 2012, 03:20:04 pm
Look at my post above. The digitalRead needs to be in the loop.
445  Using Arduino / LEDs and Multiplexing / Re: Help with LED Bar Graph and 4017 without Delay on: September 02, 2012, 01:03:24 am
The code in the link you supply uses delay() to settle the 4017. You can probably replace that delay with delaymicroseconds() to make it faster. You actually need to leave it on for a short interval to get the pov effect happening, so I don't think you can remove all delays.
446  Using Arduino / Programming Questions / Re: Switch case? on: September 01, 2012, 06:52:43 pm
I learned something today!

BTW, the reason for using if..else rather than just straight if is that execution will stop as soon as the correct range is found. Using just if will mean every single condition will be tested even if the first if was executed as the correct case.
447  Using Arduino / Programming Questions / Re: Switch case? on: September 01, 2012, 05:31:20 pm
Switch statements can only compare to one value. If you want to use a range you will need if..else statements.

C and VB are different ...
448  Using Arduino / Sensors / Re: Simple magnetic contact switch is not working right. on: September 01, 2012, 05:25:53 pm
Couple of potential problems.

Firstly, if this a simple reed switch then you need to have it arranged with a pull up or pull down resistor to give you a valid signal. Not sure if this is the case from your description.

Secondly, in your code you never actually reads the switch. Your code needs to look like this:
Code:
#include <Serial.h>

int sensorPin = 12;

void setup(){
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
}

void loop() {
  int magnetSensor = digitalRead(sensorPin);

  if(magnetSensor == HIGH){
    Serial.println("Close!");
  }
 
  if(magnetSensor == LOW){
    Serial.println("Far...");
    delay(200);
  }
}

And you can simplify the two if statements to an if..else.
449  Using Arduino / Audio / Re: A must build Audio Project on: September 01, 2012, 01:13:57 am
Just finished building one... What an amazing little device for so few components.

Have you finished the refactored code yet?
450  Using Arduino / LEDs and Multiplexing / Re: MAX7219 and LED matrix on: September 01, 2012, 12:09:28 am
Mine was all soldered up on a 'prototype pcb' - the type with just pads around the holes. I tried the breadboard approach but 8x8 LEDs and a breadboard was a bit hard for me to handle. It is actually very easy to build one up it up, but the number of solder joints meant there were bound to be some problems.

I have read before that on this forum some people have problems with the 7219 on breadboards because the high frequency used to update the display causes weird effects on the type of 'mechanical' electrical (if that makes sense) joints used.
Pages: 1 ... 28 29 [30] 31 32 ... 48