1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Changed slaveSelectPin to a const int rather than hard coded number.

This commit is contained in:
Tom Igoe 2010-08-13 02:45:20 +00:00
parent 645d9cac85
commit ecb26ec6dc

View File

@ -30,9 +30,13 @@
// inslude the SPI library:
#include <SPI.h>
// 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);
}