when I run lcd and sd module separately, it works well.
When I run this circuit I get this on the display:
#include <SPI.h>
#include <SD.h>
#include "U8glib.h"
U8GLIB_ST7920_128X64 u8g(13,11,10, 6); //SPI
const int chipSelect = 7;
int val = 0;
int pos = 10;
void setup() {
Serial.begin(9600);
while (!Serial) { ; }
SD.begin(chipSelect);
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}
}
void loop() {
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
dataFile.println(val);
dataFile.close();
}
val++;
u8g.firstPage();
do {
//u8g.setFont(u8g_font_unifont);
u8g.setFont(u8g_font_osb21);
u8g.drawStr( pos, 22, "Yersey");
} while( u8g.nextPage() );
if(pos >= 100)
pos -= 90;
else pos++;
delay(500);
}
What am I doing wrong?