I have been working on a morse code program that will flash an led on pin 13 and also connect to my phone via bluetooth (pin 0/1) to send a new message for the program to decode and flash.
I recently got the Ethernet shield and was excited about the SD card slot. I put it on and tried a few of the examples first to get a feel for it, then all I did was add a few lines to my original program and now any pin that I setup will not flash the LED. I changed the led pin to 2 now and found out that by removing the (#include <SD.h>) from the program the led flashes but it I add it the led stops working. And this will happen for any pin that I select. Now it seems odd just by adding one line to a program will stop all output pin traffic.
I changed the led pin to 2 now and found out that by removing the (#include <SD.h>) from the program the led flashes but it I add it the led stops working.
Where, in that code, are you defining pin 2 to be an output pin?
I am changing it in my program here #define LEDPin 2
after I call the include
Saying "I am going to talk to pin 2" and saying "pinMode(2, OUTPUT);" are not quite the same thing, are they?
If you want to turn an LED on, you must connect it to a pin whose mode is OUTPUT. The pins are all INPUT by default.
you don't know what I am talking about and your starting to get off topic. I am having a problem with #include <SD.h>
In my program I use #define LEDPin 2 as a constant so I am not repeating changes several times in my program. So be more specific:
At the start I have
#include <SD.h>
#define LEDPin 2
In setup() I have
pinMode(LEDPin, OUTPUT);
pinMode(10, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
}
And in loop() I have a bunch of things that make the LED go ON and OFF
Now to get back on topic the problem is that as soon as I add any code related to the SD Library (even the include statement) my led will stop working no matter what pin I have it on.
sd.h library may be taking control of the SPI pins D11-12-13, and expecting one other to be an output for Chip Select.
Don't know why that would affect other pins.
I have also the same problem =( =( =( when i'm trying to combine tvout(which uses output pin)with the sd.h or other sd libraries.
When i put the sd library,the tvout demoPAL stop playing.After searching a lot,i found that someone found a solution
to make the output pins working the output pins
but i can't understand what is he saying...Could anyone help???
Just adding SD.h takes over 500 bytes of additional RAM and this may cause your program to fail if you are already using a lot of RAM. I think tvout can use lots of RAM.
All SD libraries that write to files need a 512 byte SD block buffer for rewriting SD blocks in file structures.
fat16lib:
Just adding SD.h takes over 500 bytes of additional RAM and this may cause your program to fail if you are already using a lot of RAM.
So if this is the case, how do you free up some ram without affecting my functional program.
I just checked when I compile that my program is saying "Binary sketch size: 9378 bytes (of a 32256 byte maximum)" and when I add the include SD.h the output is "Binary sketch size: 13412 bytes (of a 32256 byte maximum)"
apple32:
I have also the same problem =( =( =( when i'm trying to combine tvout(which uses output pin)with the sd.h or other sd libraries.
When i put the sd library,the tvout demoPAL stop playing.After searching a lot,i found that someone found a solution
to make the output pins working the output pins
but i can't understand what is he saying...Could anyone help???