Difference between revisions of "Magic 8 of Heart Code"
Jump to navigation
Jump to search
(Created page with " #include <SPI.h> #include <Adafruit_GFX.h> #include <TFT_ILI9163C.h> // Color definitions #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #defin...") |
|||
Line 2: | Line 2: | ||
#include <Adafruit_GFX.h> | #include <Adafruit_GFX.h> | ||
#include <TFT_ILI9163C.h> | #include <TFT_ILI9163C.h> | ||
− | + | ||
− | |||
// Color definitions | // Color definitions | ||
#define BLACK 0x0000 | #define BLACK 0x0000 | ||
Line 13: | Line 12: | ||
#define YELLOW 0xFFE0 | #define YELLOW 0xFFE0 | ||
#define WHITE 0xFFFF | #define WHITE 0xFFFF | ||
− | + | ||
#define __CS 10 | #define __CS 10 | ||
#define __DC 8 | #define __DC 8 | ||
#define __RST 9 | #define __RST 9 | ||
− | + | ||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST); | TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST); | ||
− | + | ||
//Messages | //Messages | ||
char* myStrings[]={"Be Mine","Be My Arduino","Love You","Hack Me","XOXO", | char* myStrings[]={"Be Mine","Be My Arduino","Love You","Hack Me","XOXO", | ||
Line 31: | Line 30: | ||
//Font Size | //Font Size | ||
int font[] = {2,1,2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; | int font[] = {2,1,2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; | ||
− | + | ||
− | |||
void setup() | void setup() | ||
{ | { | ||
Line 45: | Line 43: | ||
} | } | ||
− | + | ||
void loop() | void loop() | ||
{ | { |
Latest revision as of 01:58, 12 February 2016
#include <SPI.h> #include <Adafruit_GFX.h> #include <TFT_ILI9163C.h> // Color definitions #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF #define __CS 10 #define __DC 8 #define __RST 9 TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST); //Messages char* myStrings[]={"Be Mine","Be My Arduino","Love You","Hack Me","XOXO", "You & Me","I Heart You","E=M(C^2)","(0.0)","#1","LVL1","AWESOME","Only You", "Hug Me?","I'M Yours","WTF","LOL","YOLT","KISS ME","Raspberry PI","Legal Evil Forever" }; //Row Position int row[] = {50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50}; //Column Position int col[] = {35,35,30,35,40,30,50,50,50,50,50,50,50,50,50,50,50,50,50,50,20}; //Font Size int font[] = {2,1,2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; void setup() { tft.begin(); randomSeed(analogRead(0)); pinMode(5,OUTPUT); analogWrite(5,255); digitalWrite(5,LOW); pinMode(6,OUTPUT); analogWrite(5,255); digitalWrite(6,LOW); } void loop() { int shook = 0; int slogan; digitalWrite(6,HIGH); delay(500); digitalWrite(6, LOW); tft.setRotation(3); while (1) { if ((analogRead(1) > 600) || (analogRead(1) < 400)) shook = 1; if ((analogRead(2) > 600) || (analogRead(2) < 400)) shook = 1; if ((analogRead(3) > 600) || (analogRead(3) < 400)) shook = 1; if (shook == 1) { for(int x=0;x<5;++x) { digitalWrite(6,HIGH); delay(500); digitalWrite(6,LOW); delay(500); } slogan = random(0,21); testText(slogan); shook =0; } } } void testText(int x) { digitalWrite(5, HIGH); tft.fillScreen(); tft.setCursor(col[x],row[x]); tft.setTextColor(WHITE); tft.setTextSize(font[x]); tft.println(myStrings[x]); delay(5000); tft.fillScreen(); digitalWrite(5,LOW); }