Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Graphics
- Runs a text-only demo on the Nokia 5110 LCD.
- The circuit:
- * Nokia 5110 Connected as follows:
- LED --> 50 Ohm --> 3.3V
- SCLK --> Pin 1 (SCLK)
- DN(MOSI) --> Pin 2 (MOSI)
- D/C --> Pin 4
- RST --> Pin 8
- SCE --> Pin 9
- GND --> GND
- Vcc --> Pin 10
- By Andrew Lindsay (Adapted by Megan Wachs and edited by Matthew Seal and Akil Srinivasan)
- */
- /*IF we are not using the Graphics or Bitmap capabilities
- of the LCD, save code space with these #defines*/
- #include <SD.h>
- const int chipSelect = 12;
- #include <nokia_5110_lcd.h>
- //LCD PINS
- #define LCD_PWR 10
- #define LCD_SCE 9
- #define LCD_RESET 8
- #define LCD_DC 4
- Nokia_5110_lcd lcd(LCD_PWR, LCD_DC, LCD_SCE, LCD_RESET);
- void initSD(){
- Serial.begin(9600);
- Serial.print("Initializing SD card...");
- // see if the card is present and can be initialized:
- if (!SD.begin(chipSelect)) {
- Serial.println("Card failed, or not present");
- // don't do anything more:
- return;
- }
- Serial.println("card initialized.");
- }
- void setup()
- {
- initSD();
- File dataFile = SD.open("datalog.txt");
- lcd.init(80); //parameter is contrast value, between 0 [low] and 127 [high]
- lcd.clear();
- if (dataFile) {
- while (dataFile.available()) {
- lcd.writeChar(dataFile.read(), MODE_NORMAL);
- delay(250);
- }
- dataFile.close();
- }
- // if the file isn't open, pop up an error:
- else {
- Serial.println("error opening datalog.txt");
- }
- }
- /* loop */
- void loop() {
- }
Advertisement
Add Comment
Please, Sign In to add comment