Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SPI.h"
- #include "Adafruit_GFX.h"
- #include "Adafruit_ILI9341.h"
- #define _cs 17 // goes to TFT CS
- #define _dc 16 // goes to TFT DC
- #define _mosi 23 // goes to TFT & eeprom MOSI
- #define _sclk 18 // goes to TFT & eeprom SCK/CLK
- #define _rst 5 // goes to TFT RESET
- #define _miso 19 // goes to eeprom MISO
- // 5v // goes to TFT & eeprom Vcc
- // Gnd // goes to TFT & eeprom Gnd
- #define EE_CS 4 // goes to eeprom cs
- Adafruit_ILI9341 tft = Adafruit_ILI9341(_cs, _dc, _rst);
- void setup() {
- Serial.begin(115200);
- Serial.println("A torles elindult");
- tft.begin();
- tft.setRotation(3);
- tft.fillScreen(ILI9341_BLACK);
- tft.setTextSize(3);
- tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
- tft.println("A torles elindult");
- pinMode(EE_CS,OUTPUT); //CS lábat kimenetre állítani
- digitalWrite(EE_CS, HIGH); //CS lábat felhúzni (inicializálás)
- SPI.begin(); //SPI inicializálni
- SPI.setDataMode(SPI_MODE3); //SPI protokol kiválasztása
- SPI.setBitOrder(MSBFIRST); //SPI byte sorrend
- delay(1000);
- digitalWrite(EE_CS, LOW);
- SPI.transfer(6);
- digitalWrite(EE_CS, HIGH);
- digitalWrite(EE_CS, LOW);
- SPI.transfer(1);
- SPI.transfer(0);
- digitalWrite(EE_CS, HIGH);
- for(unsigned int j=0; j< 65535; )
- {
- digitalWrite(EE_CS, LOW);
- SPI.transfer(6); // write enabled 6
- digitalWrite(EE_CS, HIGH);
- digitalWrite(EE_CS, LOW);
- SPI.transfer(2); // write 2,0
- SPI.transfer(j >>8); //a cím felső 8 bit-je
- SPI.transfer(j & 0x00FF); //a cím alsó 8 bit-je
- SPI.transfer(j); //a menteni kívánt adat beírása
- digitalWrite(EE_CS, HIGH);
- delay(4); //4 ms míg beírja az értéket az eepromba
- Serial.println(j);
- j++;
- digitalWrite(EE_CS, LOW);
- SPI.transfer(4); // write disabled 4
- digitalWrite(EE_CS, HIGH);
- }
- tft.fillScreen(ILI9341_BLACK);
- tft.println("Kesz!");
- }
- void loop(void) {
- }
Advertisement
Add Comment
Please, Sign In to add comment