Hello,
I have Arduino Micro and Arduino TFT display. I want to display one of 8 bmp images on the screen by the simple 8 buttons.
I write the code like this:
#include <SPI.h>
#include <SD.h>
#include <TFT.h>
#define sd_cs 8
#define lcd_cs 7
#define dc 0
*#define rst 1 *
TFT screen = TFT(lcd_cs, dc, rst);
-
PImage one, two, three, four, five, six, seven, eight;*
void setup() { -
pinMode(2, INPUT);*
-
pinMode(3, INPUT);*
-
pinMode(4, INPUT);*
-
pinMode(5, INPUT);*
-
pinMode(6, INPUT);*
-
pinMode(9, INPUT);*
-
pinMode(10, INPUT);*
-
pinMode(11, INPUT);*
-
screen.begin();*
-
SD.begin(sd_cs);*
-
screen.background(255, 255, 255);*
-
one = screen.loadImage("one.bmp");*
-
two = screen.loadImage("two.bmp");*
-
three = screen.loadImage("three.bmp");*
-
four = screen.loadImage("four.bmp");*
-
five = screen.loadImage("five.bmp");*
-
six = screen.loadImage("six.bmp");*
-
seven = screen.loadImage("seven.bmp");*
-
eight = screen.loadImage("eight.bmp");*
}
void loop() {
- if (digitalRead(2) == HIGH){*
- screen.image(one, 0, 0);*
- while (digitalRead(2) == HIGH){};*
} - if (digitalRead(3) == HIGH){*
- screen.image(two, 0, 0);*
- while (digitalRead(3) == HIGH){};*
} - if (digitalRead(4) == HIGH){*
- screen.image(three, 0, 0);*
- while (digitalRead(4) == HIGH){};*
} - if (digitalRead(5) == HIGH){*
- screen.image(four, 0, 0);*
- while (digitalRead(5) == HIGH){};*
} - if (digitalRead(6) == HIGH){*
- screen.image(five, 0, 0);*
- while (digitalRead(6) == HIGH){};*
} - if (digitalRead(9) == HIGH){*
- screen.image(six, 0, 0);*
- while (digitalRead(9) == HIGH){};*
} - if (digitalRead(10) == HIGH){*
- screen.image(seven, 0, 0);*
- while (digitalRead(10) == HIGH){};*
} - if (digitalRead(11) == HIGH){*
- screen.image(eight, 0, 0);*
- while (digitalRead(11) == HIGH){};*
}
}
First two or three photos works fine, but other do not display, on the screen appears only lines.
Maybe it's some memory leak or smth,
Can you help me solve this problem?