user-1: I have made this If-Then-Else code, but it doesn't work.
First I tough only the analog code is wrong, but if I take a digital port, the code doesn't work either.
What did I do wrong?
int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0.00001;  // variable to

void setup() {
  pinMode(13, OUTPUT);  //LED BORD UIT
  pinMode(12, OUTPUT);  //LED4
  pinMode(11, OUTPUT);  //LED3
  pinMode(10, OUTPUT);  //LED2
  pinMode(9, OUTPUT);   //LED1
  pinMode(8, OUTPUT);   //Elektro Magneet
  pinMode(A0, INPUT);
}

void loop() {
  if (A0 == HIGH) {
     digitalWrite(13, LOW); 
     digitalWrite(12, HIGH);   //LED on, magnet off
     digitalWrite(11, HIGH);   
     digitalWrite(10, HIGH);   
     digitalWrite(9, HIGH);
     digitalWrite(8, LOW);     

  } else {    
     digitalWrite(13, LOW); 
     digitalWrite(12, LOW);   // LED Off, magnet on
     digitalWrite(11, LOW);   
     digitalWrite(10, LOW);   
     digitalWrite(9, LOW);      
     digitalWrite(8, HIGH);     
  }
}


user368: You're comparing the pin variable value with HIGH. If you want to get the value at a digital input then you need to use digitalRead().

user407: You have defined your pin as
int sensorPin = A0;

Which should be replaced with
#define sensorPin = A0

And then in your code, you need to read the value from  the pin in your if statement:
 if (digitalRead(sensorPin) == HIGH) {


user46: Replace the line:
  if (A0 == HIGH) {

by this one:
  if (digitalRead(A0) == HIGH) {

If you plan on using the pin back as an analog input, use something like this:
  if (analogRead(A0) > 512) {

The explanation is what Ignacio said: you were comparing the pin "name" A0 directly to HIGH instead of reading from the input named A0. To make it clearer, the two lines are equivalent:
if (A0 == HIGH)
if (0 == HIGH)

Get it?
There's more about what pin names to use with digitalRead() and analogRead() here: 

analogRead(0) or analogRead(A0) at EE.SE.


-1: <p>I have made this If-Then-Else code, but it doesn't work.</p>

<p>First I tough only the analog code is wrong, but if I take a digital port, the code doesn't work either.</p>

<p>What did I do wrong?</p>

<pre><code>int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0.00001;  // variable to

void setup() {
  pinMode(13, OUTPUT);  //LED BORD UIT
  pinMode(12, OUTPUT);  //LED4
  pinMode(11, OUTPUT);  //LED3
  pinMode(10, OUTPUT);  //LED2
  pinMode(9, OUTPUT);   //LED1
  pinMode(8, OUTPUT);   //Elektro Magneet
  pinMode(A0, INPUT);
}

void loop() {
  if (A0 == HIGH) {
     digitalWrite(13, LOW); 
     digitalWrite(12, HIGH);   //LED on, magnet off
     digitalWrite(11, HIGH);   
     digitalWrite(10, HIGH);   
     digitalWrite(9, HIGH);
     digitalWrite(8, LOW);     

  } else {    
     digitalWrite(13, LOW); 
     digitalWrite(12, LOW);   // LED Off, magnet on
     digitalWrite(11, LOW);   
     digitalWrite(10, LOW);   
     digitalWrite(9, LOW);      
     digitalWrite(8, HIGH);     
  }
}
</code></pre>
 368: <p>You're comparing the pin variable value with <code>HIGH</code>. If you want to get the value <em>at a digital input</em> then you need to use <a href="http://arduino.cc/en/Reference/digitalRead" rel="nofollow"><code>digitalRead()</code></a>.</p>
 407: <p>You have defined your pin as</p>

<pre><code>int sensorPin = A0;
</code></pre>

<p>Which should be replaced with</p>

<pre><code>#define sensorPin = A0
</code></pre>

<p>And then in your code, you need to read the value from  the pin in your <code>if</code> statement:</p>

<pre><code> if (digitalRead(sensorPin) == HIGH) {
</code></pre>
 46: <p>Replace the line:</p>

<pre><code>  if (A0 == HIGH) {
</code></pre>

<p>by this one:</p>

<pre><code>  if (digitalRead(A0) == HIGH) {
</code></pre>

<p>If you plan on using the pin back as an analog input, use something like this:</p>

<pre><code>  if (analogRead(A0) &gt; 512) {
</code></pre>

<p>The explanation is what Ignacio said: you were comparing the pin "name" <code>A0</code> directly to <code>HIGH</code> instead of reading from the input named <code>A0</code>. To make it clearer, the two lines are equivalent:</p>

<pre><code>if (A0 == HIGH)
if (0 == HIGH)
</code></pre>

<p>Get it?</p>

<p>There's more about what pin names to use with digitalRead() and analogRead() here: </p>

<ul>
<li><a href="https://electronics.stackexchange.com/questions/67087/analogread0-or-analogreada0">analogRead(0) or analogRead(A0) at EE.SE</a>.</li>
</ul>
