/*

CS >>> D10
SCLK >> D13
DI  >>> D11
PA0  VCC
PBO  GND
PW0  >>> led.
*/

#include <SPI.h> int TensionLue = 1; int TensionBrute = 0; float Voltage = 0; const int CS= 10;

void setup() {

pinMode (CS, OUTPUT);
Serial.begin(9600);
SPI.begin();

}

void loop() {

  for (int i = 0; i <= 255; i++)
  {
    digitalPotWrite(i);
    delay(10);
    TensionBrute = analogRead( TensionLue);
    Voltage = (TensionBrute * 5.0 )/ 1024.0;
    //Serial.print("Level = " );
    //Serial.print(i);
    Serial.print("\t Voltage = ");
    Serial.println(Voltage,3);
  }
  delay(500);
  for (int i = 255; i >= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
    TensionBrute = analogRead( TensionLue);
    Voltage = (TensionBrute * 5.0 )/ 1024.0;
    //Serial.print("Level = " );
    //Serial.print(i);
    Serial.print("\t Voltage = ");
    Serial.println(Voltage,3);
  }

}

int digitalPotWrite(int value) {

digitalWrite(CS, LOW);
SPI.transfer(B00010001);
SPI.transfer(value);
digitalWrite(CS, HIGH);

}