A #define is a macro.
When the C preprocessor sees the macro name it substitutes the macro value as a simple 1:1 text replacement.
just to see if i did understand the working of the array.
im i doing it right ?
/* Declaration of I/Os */
int moisture_input [] = {1,3,4,5}; // Analog Input pin 1 connected to collect Soil Moisture reading.
#define dcSource_top 13 // Power source 5V top connected to digitsl pin 13
#define dcSource_bottom 12 // Power Source 5V bottom connected to digital pin 12
/*--------------------------------------------------------------------*/
int Moisture[4]; // Analogical value obtained from the experiment S.probes (1,2,3,4)
void setup (){
Serial.begin (9600);
}
int SoilMoisture(){
// Variable to hold value from Moisture input.
int reading[4];
// Set driver pins to outputs
pinMode(dcSource_top,OUTPUT);
pinMode(dcSource_bottom,OUTPUT);
// Drive a current through the divider in one direction
digitalWrite(dcSource_top,LOW);
digitalWrite(dcSource_bottom,HIGH);
// Wait a moment for capacitance effects to settle
delay(1000);
// Take readings
for (int i=0; i<4; i++)
{
reading[i] = analogRead(moisture_input[i]);
//return reading[i];
}
// Reverse the current
digitalWrite(dcSource_top,HIGH);
digitalWrite(dcSource_bottom,LOW);
// Give as much time in 'reverse' as in 'forward'
delay(1000);
// stop the current
digitalWrite(dcSource_top,LOW);
}
void loop (){
for (int j=0; j<4; j++){
Moisture[j] = SoilMoisture();
}
Serial.print ("value = ");
Serial.print (Moisture[0]);
}
#define moisture_input [] = {1,3,4,5}
You can't use defines like that. Change that line to:
const int moisture_input [] = {1,3,4,5}; // Analog Input pin 1 connected to collect Soil Moisture reading.
im i doing it right ?
Better.
Seems you did not like the phrase about clarification . . sorry about that .
As long as it made you smile. ![]()
So, SoilMoisture() is defined as returning a value. There is no return statement, so there will be garbage on the stack that is popped off and stored in the array, each time the function ends. If that's what you want, carry on.
const int moisture_input [] = {1,3,4,5}; // Analog Input pin 1 connected to collect Soil Moisture reading.Here const means that the value assigned to the array wont change, like here the pin number, correct ?
Better.
Motivating.
As long as it made you smile.
I shall make the effort to always
![]()
So, SoilMoisture() is defined as returning a value. There is no return statement, so there will be garbage on the stack that is popped off and stored in the array, each time the function ends. If that's what you want, carry on.
oops i think i forget to remove the // coment line here :
for (int i=0; i<4; i++)
{
reading[i] = analogRead(moisture_input[i]);
return reading[i]; >> remove // coment
}
if that is correct i shall be moving towards the reading of the switch.
I did not yet upload, may be this afternooon after work.
Thanks
Taz ...
for (int i=0; i<4; i++)
{
reading[i] = analogRead(moisture_input[i]);
return reading[i]; >> remove // coment
}
You really don't want to remove the comment - think what will happen.
Edit: Or, more to the point, think what will not happen.
Lux and lumens are units of brightness to human eyes which are most sensitive in yellow.
But plants reflect green and yellow, they absorb red and blue. What is best for plants does not appear so bright to human eyes or to your lux meter. You waste power on less useful wavelengths trying to increase lux, unless you're lighting for picture taking or best look. In general you want 4 red to 1 blue but you can change that some to better simulate different latitudes and time of year.
There are grow sites that you can verify this and maybe get numbers from. Red and blue leds with colored bulbs actually make good sensors for red and blue light, you need 2 pins and 1 resistor each.
human eyes which are most sensitive in yellow.
sp. "green" (550nm)
Lumens still want a lot of yellow, color of the sun.
You really don't want to remove the comment - think what will happen.
Edit: Or, more to the point, think what will not happen.
Epp im starting to have an idea what really will not happen. :~
Can you show me or more precisely give me a hint on the above please . .
Lux and lumens are units of brightness to human eyes which are most sensitive in yellow.
But plants reflect green and yellow, they absorb red and blue. What is best for plants does not appear so bright to human eyes or to your lux meter. You waste power on less useful wavelengths trying to increase lux, unless you're lighting for picture taking or best look. In general you want 4 red to 1 blue but you can change that some to better simulate different latitudes and time of year.
There are grow sites that you can verify this and maybe get numbers from. Red and blue leds with colored bulbs actually make good sensors for red and blue light, you need 2 pins and 1 resistor each.
Thats a really good piece of information. Thanks.
I think i shall be using the LDR to make known the condition of weather (Day, night, Rainy/Cloudy), so that i can switch on my T5 light based on the following:
Im pretty much interested in knowing how to get Red and Blue leds to act as good sensors. Any idea where should i start with !
A return statement says "We're done here. Go back to the caller." If you put that in the loop, on the first iteration of loop, the function will end. The remaining iterations of loop will not happen.
It really does not make sense for SoilMosture() to get data for all 4 probes, AND for you to call it 4 times.
Either it gets data for all 4 probes, and you call it once, OR, it gets data for one probe and you call it 4 times. I vote for the latter.
If green is so popular, why do plants absorb all the colors except green ?
If green is so popular, why do plants absorb all the colors except green ?
I always assumed our green sensitivity was because, as a prey animal, our ancestors would have had a significant advantage being able to distinguish things against a green background.
michinyon:
If green is so popular, why do plants absorb all the colors except green ?
If you are not a creationist, it's a matter of what worked by chance being passed down. It's not a matter of the early life being able to pick and choose.
Yellow and green are very thin slices of the light spectrum but the first light-eaters reflected violet/purple and floated in the upper layers of the sea leaving a niche below where the green ones developed. Then there was a big wipe-out that only left the green type we know today. The ancestors of those bacteria live in plant leaves.
They absorb most strongly in red and blue so that's the colors to spend on grow lights. But again, check on indoor grow sites. Sunlight is the best but that's because it's so strong and free.
A return statement says "We're done here. Go back to the caller." If you put that in the loop, on the first iteration of loop, the function will end. The remaining iterations of loop will not happen.
int reading[4];
for (int i=0; i<4; i++)
{
reading[i] = analogRead(moisture_input[i]);
return reading[i]; >> this is where i go wrong . . !!
}
> It really does not make sense for SoilMosture() to get data for all 4 probes, AND for you to call it 4 times. i got your point here . . i been able to figure out the flaws . . . :%int SoilMoisture() >> /* only one variable to hold out the return result, Only one result from int reading and rest of probes rendered useless !!
how to call for more */> Either it gets data for all 4 probes, and you call it once, OR, it gets data for one probe and you call it 4 times. I vote for the latter. i did get it here! if i need to get that data from x probes and want to call it x times, then i will need to have such a function repeated x times in my code. . ? :. :.?
They absorb most strongly in red and blue so that's the colors to spend on grow lights. But again, check on indoor grow sites. Sunlight is the best but that's because it's so strong and free.
will get hold of some good literatures on that . . i shall post links here once i come across the one . .
thanks GoForSmoke . .
taz . .
Sunlight is the best but that's because it's so strong and free.
Yeah, right. Just ask anyone living above the Arctic circle in the winter how "free" sunshine is.
Or at night. ![]()
Hello,
Here is a good link to start with the growing LEDS: http://www.stealthgrow.com/advantages.htm
Can i start up if i use normal LEDS (Red & Blue) in addition with my T5 light for experimental purpose, as i have designed a small greenhouse with volume of 2' 4" x 1' 2.5" x 4' .
You did mention about getting a red and blue led to act as a sensor for these spectrums, still not yet come across. . . !
Edit : This link is quite informative about Leds use as detectors : https://led-brdf.wikispaces.com/Led+Sensing+and+Spectral+Sensitivity
I didn't "come across" because I don't have all day to find again what you should search for yourself.
Here's the most complete doc:
http://www.merl.com/papers/docs/TR2003-35.pdf
And here's the cookbook exercise:
http://playground.arduino.cc/Learning/LEDSensor