Paso 3: Código para lector de OLED
Este bosquejo carga la biblioteca graphix y oled de adafruit.
Si carga en un arduinoUNO, incluyendo el SD.h libarary se apretar. Utiliza demasiado SRAM. Este problema puede ser corregido por:
1 - escribir código eficiente (sí... no)
2 - utilizando un Arduino mega (trabaja y confirma que es un problema de memoria)
3 - Añadir más SRAM (necesitará el SpiRAM biblioteca http://playground.arduino.cc/Main/SpiRAM y un chip físico con SRAM más
http://WW1.microchip.com/downloads/en/DeviceDoc/22... en digikey
http://www.digikey.com/Product-detail/en/23A256-I%...
4 - comente la biblioteca SD.h por ahora.
5 - reemplazar SD.h con () SdFat.h
https://github.com/greiman/SdFat )
6 - ejecutar el Teensey 3.1--un montón de memoria, código compila y carga pero no probado con OLED
Aquí está el código de la ONU sin la biblioteca de SD.h:
<span style="color: rgb(126,126,126);">///note - D10 set to output</span> <span style="color: rgb(126,126,126);">//for sd</span> <span style="color: rgb(126,126,126);">//#include <SD.h></span> #include <<span style="color: rgb(204,102,0);">SPI</span>.h> #include <<span style="color: rgb(204,102,0);">Wire</span>.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> <span style="color: rgb(126,126,126);">//////////////MPC New PINS /////////////</span> <span style="color: rgb(126,126,126);">// If using software SPI (the default case):</span> #define OLED_MOSI 11 #define OLED_CLK 13 #define OLED_DC 6 #define OLED_CS 9 #define OLED_RESET 8 Adafruit_SSD1306 <span style="color: rgb(204,102,0);">display</span>(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); <span style="color: rgb(204,102,0);">void</span> <span style="color: rgb(204,102,0);"><b>setup</b></span>() { <span style="color: rgb(204,102,0);"><b>Serial</b></span>.<span style="color: rgb(204,102,0);">begin</span>(9600); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">begin</span>(SSD1306_SWITCHCAPVCC); <span style="color: rgb(126,126,126);">// internal 3.3V line</span> <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(2000); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">pinMode</span>(10,<span style="color: rgb(0,102,153);">OUTPUT</span>); } <span style="color: rgb(204,102,0);">void</span> <span style="color: rgb(204,102,0);"><b>loop</b></span>(){ <span style="color: rgb(126,126,126);">//FlashRead Test</span> <span style="color: rgb(204,102,0);">int</span> t = 55; <span style="color: rgb(204,102,0);">int</span> x = 0; <span style="color: rgb(204,102,0);">int</span> y = 20; <span style="color: rgb(204,102,0);">int</span> s = 2; <span style="color: rgb(126,126,126);">//text scale</span> <span style="color: rgb(204,102,0);">int</span> w =12; <span style="color: rgb(126,126,126);">//pixel width of one letter</span> <span style="color: rgb(204,102,0);">display</span>.setTextSize(s); <span style="color: rgb(204,102,0);">display</span>.setTextColor(WHITE); <span style="color: rgb(126,126,126);">//is this needed?</span> <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(0,0); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"t="</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(t); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">println</span>(<span style="color: rgb(0,102,153);">","</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"Size="</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(s); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(1000); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">delay</span>(2000); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1.5*w,y); <span style="color: rgb(126,126,126);">// x = screen width - letter count x letter width</span> <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"Now, "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(204,102,0);">delay</span>(2*t); <span style="color: rgb(126,126,126);">//punctuations get 2t</span> <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"is "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(126,126,126);">//minimum is 3t</span> <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1.5*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"the "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-3*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"winter "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(5*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"of "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(126,126,126);">//minimum is 3t</span> <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1.5*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"our "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-5*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"discontent "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(10*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-2*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"made "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(4*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-4*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"glorious "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(8*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-3*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"summer "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(6*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"by "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(126,126,126);">//minimum is 3t</span> <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-2*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"this "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(4*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1.5*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"son "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-1*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"of "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(3*t); <span style="color: rgb(126,126,126);">//minimum is 3t //minimum is 3t //minimum is 3t</span> <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">setCursor</span>(64-2*w,y); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">print</span>(<span style="color: rgb(0,102,153);">"York. "</span>); <span style="color: rgb(204,102,0);">display</span>.<span style="color: rgb(204,102,0);">display</span>(); <span style="color: rgb(204,102,0);">delay</span>(5*t); <span style="color: rgb(204,102,0);">display</span>.clearDisplay(); <span style="color: rgb(204,102,0);">delay</span>(2000); }