Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Math issue inverting the value of a slide potentiometer on: August 14, 2011, 11:57:20 pm
1024-x is the more standard way to write (0-x)+1024.  Additionally, the maximum value for an int is 32,767 so multiplying anything larger than 327 by 100 will result in an overflow error.  Declare val as long.
2  Using Arduino / Project Guidance / Re: Absence sensor on: August 14, 2011, 11:41:34 pm
This recent thread covered exactly what you want  http://arduino.cc/forum/index.php/topic,68406.0.html
3  Using Arduino / Programming Questions / Re: How to write this piece of code shorter? [SOLVED] on: August 13, 2011, 05:42:43 pm
oops. did not see that.   smiley-red
4  Using Arduino / Programming Questions / Re: How to write this piece of code shorter? [SOLVED] on: August 13, 2011, 03:55:32 pm
Even shorter

Code:
while(finder.findUntil("DT", "\n\r")){
    int val = finder.getValue();
    ip[(val-1)%4] = finder.getValue();
}

EDIT: This assumes that the first read of val can only return values 1-12.  If that is not a good assumption, then adding an if(val >= 1 && val <= 12) would be needed.

EDIT2: oops, ignore this post
5  Using Arduino / General Electronics / Re: How do i read this? on: August 10, 2011, 10:11:04 pm
Quick google search for "glossary of electronics symbols" gave this page which looks like a useful starting place for reading schematics  http://www.kpsec.freeuk.com/symbol.htm
6  Using Arduino / LEDs and Multiplexing / Re: TLC5940 With IR sensor problem on: August 09, 2011, 10:48:04 pm
Have you tried adding capacitance to the trigger side?  A capacitor between A0 and ground may reduce your trigger noise.  Put in a resistor as well and you can fine tune a low pass filter on your input (reject noise with frequency >1/RC).
7  Using Arduino / Programming Questions / Re: ONE BUTTON TWO FUNCTIONS ? HELP!! on: August 09, 2011, 10:19:17 pm
One way to go about this would be with a color state array, and the index for the array counts up or down with the short press of your two buttons.  Something like:

Code:
int ledPins[] = {3,5,6}; //red, green, blue pins
int colorArray[][] = {
                             {0, 0, 0},  //all colors off
                             {1, 0, 0},  //just red on
                             {0, 1, 1},  //green and blue on
                             {1, 1, 1}   //all colors on... etc.  Add all the state you want
                             };
int colorState;  //variable that changes value from 0 to # of states when button pressed
.
.
.
//All kinds of code
.
.
.
for(int i=0; i<3; i++){
   if(colorArray[colorState][i]) analogWrite(ledPins[i],brightness);
   else analogWrite(ledPins[i], 0);
}
 //if colorState ==1, for instance, the above would turn on Red and turn off blue and green

I'm not sure if I have the syntax just right for a 2D array (it's been awhile), but hopefully you get the idea of how it would be done.
8  Using Arduino / LEDs and Multiplexing / Re: TLC5940 With IR sensor problem on: August 09, 2011, 05:29:32 pm
It looks to me like a noise problem on the trigger circuit being caused by the LED's circuit.  The decoupling schemes will hopefully work, but here are some more ways to explore the problem if you haven't done them already:

- change the trigger from (threshold - 7) to -14, -100,..
- set threshold in setup with the LED's on
- change wait time from 500 to 100, 50,...
9  Using Arduino / LEDs and Multiplexing / Re: TLC5940 With IR sensor problem on: August 09, 2011, 01:39:57 am
Maybe you could give us a sketch of your entire circuit (including all wires, resistors, de-coupling capacitors,etc. and where they are) and someone might be able to locate the issue.  I think we've ruled out your code as the source of the problem.
10  Using Arduino / LEDs and Multiplexing / Re: TLC5940 With IR sensor problem on: August 08, 2011, 03:16:07 pm
Have you tried monitoring the RecieverVal yet?  My bet is that your trigger, which is an optical device, is getting interference from the lights being on.  I'm not sure how you have things set up, but you might try completely shielding your trigger from your lights with a piece of cardboard or something.
11  Using Arduino / Project Guidance / Re: Fading RGB Clock on: August 06, 2011, 10:25:18 pm
OP: do you intend for the lights to "hand off" to one another, or just one on at a time?  By "hand off" I mean that as soon as light #2 starts to dim light #3 starts to brighten. One at a time would be light #3 does not brighten until #2 is off.
12  Using Arduino / Project Guidance / Re: Fading RGB Clock on: August 06, 2011, 09:33:19 pm
If I understand your question correctly, I think you could bypass your TimeBrightness array and use some creative mod'ing.

Code:
secBrightness = millis() % 5000; //some value between 0 and 5000 that restarts every 5 seconds
if(secBrightness > 2500) secBrightness = 5000 - secBrightness; //after 2.5 seconds start counting down instead of up
secBrightness *= peakFactor;

This would give brightness from 0 to peakFactor*2500 to 0 every 5 seconds and will be very smooth assuming the function gets called at least a few times a second.  A similar routine for minutes and hours would also work.  I assume the seconds() from time.h is aligned with millis()... that is seconds() changes value exactly when millis() % 1000 = 0.

Also, in my example you get 0 intensity on the time marks and full intensity halfway between time marks.  I'll let you figure how to fudge things to have full intensity on the time marks.
13  Using Arduino / LEDs and Multiplexing / Re: TLC5940 With IR sensor problem on: August 05, 2011, 10:19:49 pm
Try adding a Serial.println() to monitor ReceiverVal.  You want to determine if the problem is with the input from the trigger or with the output to the Tlc.
14  Using Arduino / Programming Questions / Re: SOLVED - - - Stopwatch / blink without delay problem on: August 05, 2011, 01:14:52 am
Sweet!  Glad you got it working.  Does it makes sense to you now how it works?

I don't think it should matter if you switch the lights in the if statements or not.  I would still be suspicious of flaky hardware.
15  Using Arduino / Programming Questions / Re: Stopwatch / blink without delay problem on: August 04, 2011, 10:24:36 pm
The code looks good to me.  Check that your hardware is still working.  Is your photodiode trigger still aligned with the receiver and / or the photodiode still emitting?
Pages: [1] 2 3