Tady je program a schéma od uživatele** Standa_58**
[code]#include <ctype.h>
#include <SPI.h>
#include <SD.h>
#define bit9600Delay 100
#define halfBit9600Delay 50
#define bit4800Delay 188
#define halfBit4800Delay 94
File myFile;
byte rx = 6;
byte tx = 7;
byte SWval;
int DTR = 8;
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
if (!SD.begin(4)) {
Serial.println(“initialization failed!”);
return;
}
pinMode(rx,INPUT);
pinMode(tx,OUTPUT);
digitalWrite(tx,HIGH);
delay(2);
digitalWrite(13,HIGH); //turn on debugging LED
// open the file for reading:
myFile = SD.open(“test1.txt”);
if (myFile) {
// read from the file until there's nothing else in it:
while (myFile.available()) {
SWprint(myFile.read());
}
// close the file:
myFile.close();
}
Serial.println(“Konec”);
}
void SWprint(int data)
{
byte mask;
while (digitalRead(DTR)) {
// čekánà když je plná paměť
}
//startbit
digitalWrite(tx,LOW);
delayMicroseconds(bit9600Delay);
for (mask = 0x01; mask>0; mask <<= 1) {
if (data & mask){ // choose bit
digitalWrite(tx,HIGH); // send 1
}
else{
digitalWrite(tx,LOW); // send 0
}
delayMicroseconds(bit9600Delay);
}
//stop bit
digitalWrite(tx, HIGH);
delayMicroseconds(bit9600Delay);
}
int SWread()
{
byte val = 0;
while (digitalRead(rx));
//wait for start bit
if (digitalRead(rx) == LOW) {
delayMicroseconds(halfBit9600Delay);
for (int offset = 0; offset < 8; offset++) {
delayMicroseconds(bit9600Delay);
val |= digitalRead(rx) << offset;
}
//wait for stop bit + extra
delayMicroseconds(bit9600Delay);
delayMicroseconds(bit9600Delay);
return val;
}
}
void loop()
{
}[/code]
A jinak tisknu přes CMD ve WIN7. Ale někdy se tomu FAKT nechce. Tohle bude jednodušší možná, Objednám shield a pak to testnu.