Show Posts
|
|
Pages: 1 ... 9 10 [11]
|
|
152
|
Using Arduino / Programming Questions / Re: Random()
|
on: November 19, 2012, 07:43:06 pm
|
Hi iluvplanes, There seems to be a few other discussions happening here... I'll try to address your comment: What the code does is flash each LED once, making sure that each is flashed only once. If you are happy with your code, then ignore me... But I believe your software won't do what you wanted. (1) the way you check for repeated random numbers wont guarantee that an LED wont repeat (walk through your code with the sequence: 2 3 2 3) and, (2) the whole thing is in a loop, so this will all happen more than once. Just trying to help. I hope I'm not being too picky!
|
|
|
|
|
153
|
Using Arduino / Programming Questions / Re: Random()
|
on: November 18, 2012, 11:40:39 am
|
|
Hi iluvplanes,
Just a few coding observations that can make your code easier to read and easier to understand:
You have 2 delays, 3 sec at the beginning of your loop and 1 sec at the bottom of the loop, that can be combined into a single delay.
// Comments help to explain what you are doing. I had to read through the code to determine the following:
It appears that you have a loop cycle time of 6.8 seconds when you add all of the delays. Within this time you would like to randomly flash some LEDs for 0.7 seconds.
From your code, it appears that you can flash an LED multiple times in the cycle--just not twice in a row, and that within a cycle it is ok if an LED doesn't flash at all. If not, then Nick's shuffle approach is the way to go.
That said... This was probably just supposed to be a fun activity and now that you've gotten it to work, you can move on to other things! FUN, FUN, FUN. If you're looking for something to tweak (and something to learn), maybe use potentiometers to vary the loop delay and on/off delays?
|
|
|
|
|
154
|
Using Arduino / Programming Questions / Re: Programming Question..?
|
on: November 18, 2012, 10:58:10 am
|
Wildbill is correct about readability. Along those lines, you should also use constants to declare the control limits, something like: const int FAN_ON_TEMP = 75; // turn fan on at 75 degrees Fahrenheit const int FAN_OFF_TEMP = 73; // turn fan off at 73 degrees Fahrenheit And use those constants in place of the literal values in the code.
|
|
|
|
|
155
|
Using Arduino / Programming Questions / Re: Programming Question..?
|
on: November 18, 2012, 01:57:59 am
|
In order for the fan to turn off, you have to tell it to turn off. As Arrch says, you are missing some logic. Also, it is common in situations like this to add hysteresis (en.wikipedia.org/wiki/Hysteresis) and make the "turn off" temp lower than the "turn on" temp to keep the fan from turning on and off too quickly. Maybe something like: if(fTemp <= 73) digitalWrite(pin2, LOW);
|
|
|
|
|
156
|
Using Arduino / Programming Questions / Re: All pins unused pins HIGH?
|
on: November 14, 2012, 08:30:57 am
|
|
Quick side note... I'm fairly new to these forums too, and have been looking for guidance and instructions on how to post correctly. The site is large, and I haven't found anything yet -- am I looking in the wrong spots? Can you direct me to the right spot? Thanks!
Also, I thought unused pins are set to input and were pulled high by default.
Edit: interesting... Just after posting this, I saw the 'read this first...' link you mentioned (I did look before posting this, by the way). It wasn't there when I looked earlier ?! Maybe I inadvertently set a filter. Hmmm
|
|
|
|
|
158
|
Using Arduino / General Electronics / Re: Can I build a project using 4 AA batteries with a 5V Arduino board?
|
on: November 13, 2012, 10:42:21 pm
|
An Arduino will run off (eg.) 4V connected to the "5V input" pin (ie. bypass the regulator) I wouldn't recommend this with latest versions of Arduino. The regulator is sensitive to being reverse driven. Add a diode from 5V (anode) to Vin (cathode) to prevent damaging the regulator. Can you elaborate on this a little? What does the diode protect, and how? Especially in a battery driven case.
|
|
|
|
|
161
|
Community / Bar Sport / Re: Does "arduino" means something?
|
on: November 03, 2012, 09:35:59 pm
|
|
From what I recall, the product was named after the cafe that the designers frequented when they were developing it. The cafe was named after a medieval king that ruled the region.
|
|
|
|
|