I have just got a W5100 Ethernet Shield. The shield comes with SD card etc.
So just playing with it I noticed a problem of the pins being set high and not able to be used when trying to initialise the SD card.
OK, I have a simple setup, an LED (with resistor) off Pin 11 and then to Gnd
I am using the following code.
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
int LEDPin = 11;
const int chipSelect = 4;
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Initializing SD card...");
if (!SD.begin(chipSelect)) {
return;
}
Serial.println("card initialized.");
}
void loop() {
analogWrite(LEDPin, 0);
}
When the code has been uploaded the LED immediate lights up with full brightness. Why? when I have set the LED pin to 0
If I comment out the following line and upload again, then it works fine.
if (!SD.begin(chipSelect)) {
return;
}
It appears to be the cmd SD.Begin that sets the others pins high..
I have had read and understand a bit about SPI. So when using the SD card I do not have access to the pins 13,12,11 and 4 for other tasks like controlling my LED
I am using data from a sensor to control the brightness of an LED and storing that sensor value on the SD Card in a file.
So I have tried using other pins for controlling my LED but none other them allow me to control the brightness. Using digital just allows high/low.
SniffTheGlove:
I have had read and understand a bit about SPI. So when using the SD card I do not have access to the pins 13,12,11 and 4 for other tasks like controlling my LED
So you know pin 11 is useful for SPI, you know SPI will do things in the background and thus you do