user27363: I am powering solenoid with 24 volt as required however I am using TIP122 
transistor that has base connected to Arduino Digital Pin 6 via a 1K Resistor. 
And the collector is connected to negative side of 1N4001 diode, this also serves as the Negative out for solenoid. and emitter is connected to the 24 volt power input.
The positive input from power source is connected to positive terminal of diode is directly connected to solenoid.

As per the logic I am trying to turn on Solenoid based on Signal from Arduino PIN 6, but for some reason Solenoid doesnt power up.
In my code below I want to turn on solenoid if soil moisture goes above 60. the signal is coming from Pin 6 but solenoid doesnt power up.
#include <SPI.h>

int solenoidPin = 6;    //This is the output pin on the Arduino we are using

int GLED = 5; // Wet Soil Indicator at Digital PIN D5
int RLED = 9; // Dry Soil Indicator at Digital PIN D9
int SENSE = 1; // Soil Sensor input at Analog PIN A1
int val = 0;

int greenLedPin = 2; // LED on pin 2
int yellowLedPin = 3;
int redLedPin = 4;

int lightSensorPin = A0;
int analogValue = 0;



void setup() {
  pinMode(solenoidPin, OUTPUT);           //Sets the pin as an output

  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  pinMode(greenLedPin, OUTPUT); // LED on pin 2
  pinMode(yellowLedPin, OUTPUT);
  pinMode(redLedPin, OUTPUT);

  pinMode(GLED, OUTPUT);
  pinMode(RLED, OUTPUT);

}

void loop() {
  val = analogRead(SENSE);
  val = val / 10;
  analogValue = analogRead(lightSensorPin);
  Serial.print("LDR value: ");
  Serial.print(analogValue);
  digitalWrite (redLedPin, analogValue < 55) ;
  digitalWrite (yellowLedPin, analogValue >= 55 && analogValue <= 100) ;
  digitalWrite (greenLedPin, analogValue > 100) ;

  Serial.print(" Soil Moisture: ");
  Serial.println(val);
  digitalWrite(GLED, (val < 50));
  digitalWrite(RLED, (val > 50));
  // Turn on Solenoid Valve if soil moisture value greater than 60
  digitalWrite(solenoidPin, (val > 60));

}

I am doubting on the diode to use , because I am  powering solenoid of 24 volt and not sure if the diode is correct , as per my knowledge, diode can get direct if higher voltage is passed. 
Any help will be greatly appreciated.

user28551: When looking your schematic and assuming that J1 connector is not powered by your MacBook as your Arduino board, the main problem is located to the GND signal.
In order to have a commutation current to the Base of the TIP122 through the 1K resistor, you need to link the GND signal its Emitter with the GND signal of your Arduino board.
See a proposed schematic from "High-Power Control: Arduino + TIP120 Transistor"


27363: <p>I am powering solenoid with 24 volt as required however I am using TIP122 </p>

<p>transistor that has base connected to Arduino Digital Pin 6 via a 1K Resistor. 
And the collector is connected to negative side of 1N4001 diode, this also serves as the Negative out for solenoid. and emitter is connected to the 24 volt power input.
The positive input from power source is connected to positive terminal of diode is directly connected to solenoid.</p>

<p><a href="https://i.stack.imgur.com/CfYcf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CfYcf.png" alt="enter image description here"></a></p>

<p>As per the logic I am trying to turn on Solenoid based on Signal from Arduino PIN 6, but for some reason Solenoid doesnt power up.</p>

<p>In my code below I want to turn on solenoid if soil moisture goes above 60. the signal is coming from Pin 6 but solenoid doesnt power up.</p>

<pre><code>#include &lt;SPI.h&gt;

int solenoidPin = 6;    //This is the output pin on the Arduino we are using

int GLED = 5; // Wet Soil Indicator at Digital PIN D5
int RLED = 9; // Dry Soil Indicator at Digital PIN D9
int SENSE = 1; // Soil Sensor input at Analog PIN A1
int val = 0;

int greenLedPin = 2; // LED on pin 2
int yellowLedPin = 3;
int redLedPin = 4;

int lightSensorPin = A0;
int analogValue = 0;



void setup() {
  pinMode(solenoidPin, OUTPUT);           //Sets the pin as an output

  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  pinMode(greenLedPin, OUTPUT); // LED on pin 2
  pinMode(yellowLedPin, OUTPUT);
  pinMode(redLedPin, OUTPUT);

  pinMode(GLED, OUTPUT);
  pinMode(RLED, OUTPUT);

}

void loop() {
  val = analogRead(SENSE);
  val = val / 10;
  analogValue = analogRead(lightSensorPin);
  Serial.print("LDR value: ");
  Serial.print(analogValue);
  digitalWrite (redLedPin, analogValue &lt; 55) ;
  digitalWrite (yellowLedPin, analogValue &gt;= 55 &amp;&amp; analogValue &lt;= 100) ;
  digitalWrite (greenLedPin, analogValue &gt; 100) ;

  Serial.print(" Soil Moisture: ");
  Serial.println(val);
  digitalWrite(GLED, (val &lt; 50));
  digitalWrite(RLED, (val &gt; 50));
  // Turn on Solenoid Valve if soil moisture value greater than 60
  digitalWrite(solenoidPin, (val &gt; 60));

}
</code></pre>

<p>I am doubting on the diode to use , because I am  powering solenoid of 24 volt and not sure if the diode is correct , as per my knowledge, diode can get direct if higher voltage is passed. </p>

<p>Any help will be greatly appreciated.</p>
 28551: <p>When looking your schematic and assuming that <strong>J1</strong> connector is not powered by your MacBook as your Arduino board, the main problem is located to the <strong>GND</strong> signal.</p>

<p>In order to have a commutation current to the <strong>Base</strong> of the TIP122 through the 1K resistor, you need to link the <strong>GND</strong> signal its <strong>Emitter</strong> with the <strong>GND</strong> signal of your Arduino board.</p>

<p>See a proposed schematic from <strong><a href="http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/" rel="nofollow noreferrer">"High-Power Control: Arduino + TIP120 Transistor"</a></strong></p>

<p><a href="https://i.stack.imgur.com/XZLEu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XZLEu.png" alt="enter image description here"></a></p>
