daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*********************
  2.  
  3. Example code for the Adafruit RGB Character LCD Shield and Library
  4.  
  5. This code displays text on the shield, and also reads the buttons on the keypad.
  6. When a button is pressed, the backlight changes color.
  7.  
  8. **********************/
  9.  
  10. // include the library code:
  11. #include <Wire.h>
  12. #include <Adafruit_RGBLCDShield.h>
  13. //#include <Adafruit_MCP23017.h>
  14.  
  15.  
  16. byte heart[8] = {
  17.   0b00000,
  18.   0b01010,
  19.   0b11111,
  20.   0b11111,
  21.   0b11111,
  22.   0b01110,
  23.   0b00100,
  24.   0b00000
  25. };
  26.  
  27. // The shield uses the I2C SCL and SDA pins. On classic Arduinos
  28. // this is Analog 4 and 5 so you can't use those for analogRead() anymore
  29. // However, you can connect other I2C sensors to the I2C bus and share
  30. // the I2C bus.
  31. Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
  32.  
  33. // These #defines make it easy to set the backlight color
  34. #define RED 0x1
  35. #define YELLOW 0x3
  36. #define GREEN 0x2
  37. #define TEAL 0x6
  38. #define BLUE 0x4
  39. #define VIOLET 0x5
  40. #define WHITE 0x7
  41.  
  42. void setup() {
  43.   // Debugging output
  44.   Serial.begin(9600);
  45.   // set up the LCD's number of columns and rows:
  46.   lcd.begin(16, 2);
  47.  
  48.   // Print a message to the LCD. We track how long it takes since
  49.   // this library has been optimized a bit and we're proud of it :)
  50.   int time = millis();
  51.   lcd.print("Hi, my name is:");
  52.   lcd.setCursor(0, 1);
  53.   lcd.print("Yuuki");
  54.   time = millis() - time;
  55.   Serial.print("Took "); Serial.print(time); Serial.println(" ms");
  56.   lcd.setBacklight(WHITE);
  57.   lcd.createChar(0, heart);
  58.  
  59. }
  60.  
  61. String message[10] = {"Why can't we getalong","You're *hilarious*","Kappa","This speedrun   sucks.","Mobile Quotewall <3 <3 <3 <3 <3 ","ayy lmao","Well isnt that  Lewd~ <3","Gosh Heckie","@w@","awuwuwuwuwuwuwu!"};
  62. String names[19] = {"Yuuki", "Kayya", "Kilojoule Jackal", "Kaisa", "C0TT1N", "Subspace", "Balloonala", "Sparks", "Tammy", "Netasha", "Faith", "Gyro", "CHOMP", "Umbreon", "Fishbutt", "Farfetch'd", "Celeste", "Notkea", "Missed"};
  63. uint8_t i=0;
  64. int u = 0;
  65. int z = 0;
  66. void loop() {
  67.   // set the cursor to column 0, line 1
  68.   // (note: line 1 is the second row, since counting begins with 0):
  69.   lcd.setCursor(0, 1);
  70.   // print the number of seconds since reset:
  71.   //lcd.print(millis()/1000);
  72.  
  73.   uint8_t buttons = lcd.readButtons();
  74.  
  75.   if (buttons) {
  76.     lcd.clear();
  77.     lcd.setCursor(0,0);
  78.     lcd.print("Hi, my name is:");
  79.     lcd.setCursor(0,1);
  80.     if (buttons & BUTTON_UP) {
  81.       lcd.print("Yuuki");
  82.       //lcd.setBacklight(RED);
  83.     }
  84.     if (buttons & BUTTON_DOWN) {
  85.       lcd.print("Kaisa");
  86.       //lcd.setBacklight(YELLOW);
  87.     }
  88.     if (buttons & BUTTON_LEFT) {
  89.       //lcd.print(names[z]);
  90.       //z++;
  91.       //if(z<3){
  92.       //  z = 0;
  93.       //}
  94.       lcd.setCursor(0,0);
  95.       lcd.print(" I'm on Duty <3 ");
  96.       lcd.setCursor(0,1);
  97.       lcd.print(" May I help you ");
  98.       //lcd.setBacklight(GREEN);
  99.     }
  100.     if (buttons & BUTTON_RIGHT) {
  101.       lcd.print(names[z]);
  102.       z = z - 1;
  103.       if(z<0){
  104.         z = 18;
  105.       }
  106.       //lcd.setBacklight(TEAL);
  107.     }
  108.     if (buttons & BUTTON_SELECT) {
  109.       lcd.clear();
  110.       int v = random(0,10);
  111.       int len = message[v].length();
  112.       if(len > 16){
  113.         lcd.print(message[v].substring(0,16));
  114.         lcd.setCursor(0,1);
  115.         lcd.print(message[v].substring(16,len));
  116.       }else{
  117.         lcd.print(message[v]);
  118.       }
  119.       //if(message.charAt(15)){
  120.       //  lcd.print(message[v]);
  121.       //}
  122.       //lcd.print(message[v]);
  123.       //lcd.setBacklight(VIOLET);
  124.       //lcd.write(byte(0));
  125.  
  126.     }
  127.   }
  128. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top