From ecb26ec6dc7d579f501fa0c9f95f2de655735c19 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Fri, 13 Aug 2010 02:45:20 +0000 Subject: [PATCH] Changed slaveSelectPin to a const int rather than hard coded number. --- .../examples/DigitalPotControl/DigitalPotControl.pde | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde index 54a46051b..ef97dae88 100644 --- a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde +++ b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde @@ -30,9 +30,13 @@ // inslude the SPI library: #include + +// set pin 10 as the slave select for the digital pot: +const int slaveSelectPin = 10; + void setup() { - // set pin 10 as the slave select for the digital pot: - pinMode (10, OUTPUT); + // set the slaveSelectPin as an output: + pinMode (slaveSelectPin, OUTPUT); // initialize SPI: SPI.begin(); } @@ -58,10 +62,10 @@ void loop() { int digitalPotWrite(int address, int value) { // take the SS pin low to select the chip: - digitalWrite(10,LOW); + digitalWrite(slaveSelectPin,LOW); // send in the address and value via SPI: SPI.transfer(address); SPI.transfer(value); // take the SS pin high to de-select the chip: - digitalWrite(10,HIGH); + digitalWrite(slaveSelectPin,HIGH); } \ No newline at end of file