Good day,
Following code is a part of the project which i trimmed so as to post on the forum and focus on the issue.
The code works such the there are two text files on the sd card.
-
One named set.txt which values 0016, 0004 which is converted to 16 (column) and 4 9row) respectively for 2 dimension array named sequence[row][col];
-
Second file contains led blink pattern in decimal format
eg:
240,15,28,192,174,186,0,0,170,238,56,145,
255,255,227,70,207,6,151,13,130,174,3,124,
everything imports fine but all i cannot change the column and row value
please guide or point me a direction
thanking you.
#include <SPI.h>
#include <SD.h>
#define CS_PIN 10
int latchPin = 8;
int clockPin = 7;
int dataPin = 6;
int row;
int roww;
int column;
const int COL_COUNT = 12; //-------------------------------------> this column i want to change from sd card.
const int ROW_COUNT = 4; //-------------------------------------> this row i want to change from sd card.
int sequence[ROW_COUNT][COL_COUNT]= {
240,15,28,192,174,186,0,0,170,238,56,145,
255,255,227,70,207,6,151,13,130,174,3,124,
171,25,153,149,65,192,213,229,130,162,3,12,
255,255,255,255,255,255,255,255,255,255,255,255
};
void setup() {
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
if (!SD.begin(CS_PIN)) {
("begin failed");
}
File dataFile = SD.open("set.txt");
if (dataFile)
{
char a [4] = {dataFile.read(),dataFile.read(),dataFile.read(),dataFile.read()};
int column = atoi(a);
Serial.println(column);
char b = dataFile.read(); // to forget the delimiter ","
char e [4] = {dataFile.read(),dataFile.read(),dataFile.read(),dataFile.read()};
int roww = atoi(e);
Serial.println(roww);
dataFile.close();
return (roww, column);
}
return (roww, column);
}
/*
int COL_COUNT = column; this is want i was trying
int ROW_COUNT = roww; this is want i was trying
*/
void loop() {
for (int row = 0; row < ROW_COUNT; row++)
{
for (int col = 0; col < COL_COUNT; col++)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, sequence[row][4]); // deleted above 11 shift register to post
shiftOut(dataPin, clockPin, LSBFIRST, sequence[row][3]);
shiftOut(dataPin, clockPin, LSBFIRST, sequence[row][2]);
shiftOut(dataPin, clockPin, LSBFIRST, sequence[row][1]);
shiftOut(dataPin, clockPin, LSBFIRST, sequence[row][0]);
digitalWrite(latchPin, HIGH);
delay(100);
}
}
}