Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_GFX.h>
- #include <MCUFRIEND_kbv.h>
- MCUFRIEND_kbv tft;
- #define BLACK 0x0000
- #define LIGHTBLUE 0x34DF
- #define BLUE 0x001F
- #define VERYDARKBLUE 0x0005
- #define LIGHTRED 0xF945
- #define RED 0xF800
- #define DARKRED 0x8800
- #define VERYDARKRED 0x3800
- #define GREEN 0x07E0
- #define VERYDARKGREEN 0x0140
- #define KHAKIGREEN 0x195B62
- #define CYAN 0x07FF
- #define VERYDARKCYAN 0x0145
- #define MAGENTA 0xF81F
- #define VERYDARKMAGENTA 0x3803
- #define YELLOW 0xFFE0
- #define VERYDARKYELLOW 0x3180
- #define WHITE 0xFFFF
- #define VERYDARKGRAY 0x2124
- #define GRAY 0xA514
- #define ORANGE 0xFC21
- #define VERYDARKORANGE 0x4920
- uint16_t g_identifier;
- uint8_t OrientationTFT = 1;
- float value=0;
- float rev=0;
- int rpm;
- int oldtime=0;
- int time;
- void isr()
- {
- rev++;
- }
- void setup()
- {
- tft.begin(9600);
- tft.reset();
- g_identifier = tft.readID();
- tft.begin(g_identifier);
- tft.fillScreen(BLACK);
- tft.setRotation(OrientationTFT);
- attachInterrupt(0,isr,RISING);
- }
- void loop()
- {
- delay(1000);
- detachInterrupt(0);
- time=millis()-oldtime;
- rpm=(rev/time)*60000;
- oldtime=millis();
- rev=0;
- tft.setTextColor(LIGHTBLUE , BLACK);
- tft.setCursor(5, 5);
- tft.setTextSize(4);
- tft.print("___TACHOMETER___");
- tft.setCursor(5,50);
- tft.print( rpm);
- tft.setCursor(60,50);
- tft.print(" RPM");
- attachInterrupt(0,isr,RISING);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement