Devices & Components
1
Arduino Uno Rev3
1
RGB Backlight LCD - 16x2
1
Pushbutton switch 12mm
Software & Tools
Arduino IDE
Project description
Code
The code for random story
arduino
It also does a random RGB color too!
1#include <LiquidCrystal.h> 2 3#include <Wire.h> 4#include "rgb_lcd.h" 5 6rgb_lcd lcd; 7 8int delaytime = 200; 9int randomcolorsR = 0; 10int randomcolorsG = 0; 11int randomcolorsB = 0; 12int randomNum1 = random(0, 19); 13int randomNum2 = random(0, 19); 14 15byte customChar[8] = { 16 0b01110, 17 0b10001, 18 0b11111, 19 0b11001, 20 0b11001, 21 0b11111, 22 0b10001, 23 0b01110 24}; 25 26 27 28 29 30String msgs1[]= {"The killers","The victims","Their friends","The guards","The dead","The living","The funerals","Underworlds","Mourners", "Mortals","Demons","The potions","People","The evils","Nightmares","Hauntings","The survivors","Graveyards","Deaths","Phantoms"}; 31String msgs2[] = {"are back now...","are repulsive...","are gross...","are weird...","are evil...","had gore...","had saftey...","had no brains...","had no end...","began it...","awakened...","kill mortals...","created hell...","forbid help...","won't stop...","resists others...","didn't work...","started it...","rised...","started war..."}; 32 33//I need to replace these "msg1" and msgs 2 with more logical (and more through) matches! 34// as of oct 17 this has been (i think) completed 35 36 37void setup() 38{ 39 lcd.begin(16, 2); 40 randomSeed(analogRead(A0)); 41 Serial.begin(9600); 42 lcd.createChar(0, customChar); 43 pinMode(4, INPUT); // set pin to input 44 digitalWrite(4, HIGH); // turn on pullup resistors 45 46} 47 48void loop() 49{ 50 if(digitalRead(4) == LOW) 51 { 52 53 lcd.clear(); 54 randomcolorsR = random(0, 255); 55 randomcolorsG = random(0, 255); 56 randomcolorsB = random(0, 255); 57 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 58 randomNum1 = random(0, 19); 59 randomNum2 = random(0, 19); 60 lcd.setCursor(0, 0); 61 lcd.print(msgs1[randomNum1]); 62 lcd.setCursor(0, 1); 63 lcd.print(msgs2[randomNum2]); 64 delay(3000); 65 lcd.clear(); 66 67 lcd.clear(); 68 randomcolorsR = random(0, 255); 69 randomcolorsG = random(0, 255); 70 randomcolorsB = random(0, 255); 71 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 72 randomNum1 = random(0, 19); 73 randomNum2 = random(0, 19); 74 lcd.setCursor(0, 0); 75 lcd.print(msgs1[randomNum1]); 76 lcd.setCursor(0, 1); 77 lcd.print(msgs2[randomNum2]); 78 delay(3000); 79 lcd.clear(); 80 81 lcd.clear(); 82 randomcolorsR = random(0, 255); 83 randomcolorsG = random(0, 255); 84 randomcolorsB = random(0, 255); 85 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 86 randomNum1 = random(0, 19); 87 randomNum2 = random(0, 19); 88 lcd.setCursor(0, 0); 89 lcd.print(msgs1[randomNum1]); 90 lcd.setCursor(0, 1); 91 lcd.print(msgs2[randomNum2]); 92 delay(3000); 93 lcd.clear(); 94 95 lcd.clear(); 96 randomcolorsR = random(0, 255); 97 randomcolorsG = random(0, 255); 98 randomcolorsB = random(0, 255); 99 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 100 randomNum1 = random(0, 19); 101 randomNum2 = random(0, 19); 102 lcd.setCursor(0, 0); 103 lcd.print(msgs1[randomNum1]); 104 lcd.setCursor(0, 1); 105 lcd.print(msgs2[randomNum2]); 106 delay(3000); 107 lcd.clear(); 108 109 110 randomcolorsR = (0, 255); 111 randomcolorsG = (0, 255); 112 randomcolorsB = (0, 255); 113 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 114 lcd.setCursor(6, 0); 115 lcd.print("fin"); 116 delay(900); 117 lcd.clear(); 118 119 randomcolorsR = (0, 255); 120 randomcolorsG = (0, 255); 121 randomcolorsB = (0, 255); 122 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 123 lcd.setCursor(1, 0); 124 lcd.write((uint8_t)0); 125 lcd.setCursor(3,0); 126 lcd.print("noah hellman"); 127 lcd.setCursor(6,1); 128 lcd.print("2016"); 129 delay(800); 130 131 132 } 133 else 134 { 135 noah(); 136 } 137} 138 139void noah() 140{ 141 randomcolorsR = (0, 255); 142 randomcolorsG = (0, 255); 143 randomcolorsB = (0, 255); 144 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 145 lcd.setCursor(0, 0); 146 lcd.print("Press for a grim"); 147 lcd.setCursor(2, 1); 148 lcd.print("4 line poem!"); 149} 150 151 152 153 154
The code for random story
arduino
It also does a random RGB color too!
1#include <LiquidCrystal.h> 2 3#include <Wire.h> 4#include "rgb_lcd.h" 5 6rgb_lcd lcd; 7 8int delaytime = 200; 9int randomcolorsR = 0; 10int randomcolorsG = 0; 11int randomcolorsB = 0; 12int randomNum1 = random(0, 19); 13int randomNum2 = random(0, 19); 14 15byte customChar[8] = { 16 0b01110, 17 0b10001, 18 0b11111, 19 0b11001, 20 0b11001, 21 0b11111, 22 0b10001, 23 0b01110 24}; 25 26 27 28 29 30String msgs1[]= {"The killers","The victims","Their friends","The guards","The dead","The living","The funerals","Underworlds","Mourners", "Mortals","Demons","The potions","People","The evils","Nightmares","Hauntings","The survivors","Graveyards","Deaths","Phantoms"}; 31String msgs2[] = {"are back now...","are repulsive...","are gross...","are weird...","are evil...","had gore...","had saftey...","had no brains...","had no end...","began it...","awakened...","kill mortals...","created hell...","forbid help...","won't stop...","resists others...","didn't work...","started it...","rised...","started war..."}; 32 33//I need to replace these "msg1" and msgs 2 with more logical (and more through) matches! 34// as of oct 17 this has been (i think) completed 35 36 37void setup() 38{ 39 lcd.begin(16, 2); 40 randomSeed(analogRead(A0)); 41 Serial.begin(9600); 42 lcd.createChar(0, customChar); 43 pinMode(4, INPUT); // set pin to input 44 digitalWrite(4, HIGH); // turn on pullup resistors 45 46} 47 48void loop() 49{ 50 if(digitalRead(4) == LOW) 51 { 52 53 lcd.clear(); 54 randomcolorsR = random(0, 255); 55 randomcolorsG = random(0, 255); 56 randomcolorsB = random(0, 255); 57 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 58 randomNum1 = random(0, 19); 59 randomNum2 = random(0, 19); 60 lcd.setCursor(0, 0); 61 lcd.print(msgs1[randomNum1]); 62 lcd.setCursor(0, 1); 63 lcd.print(msgs2[randomNum2]); 64 delay(3000); 65 lcd.clear(); 66 67 lcd.clear(); 68 randomcolorsR = random(0, 255); 69 randomcolorsG = random(0, 255); 70 randomcolorsB = random(0, 255); 71 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 72 randomNum1 = random(0, 19); 73 randomNum2 = random(0, 19); 74 lcd.setCursor(0, 0); 75 lcd.print(msgs1[randomNum1]); 76 lcd.setCursor(0, 1); 77 lcd.print(msgs2[randomNum2]); 78 delay(3000); 79 lcd.clear(); 80 81 lcd.clear(); 82 randomcolorsR = random(0, 255); 83 randomcolorsG = random(0, 255); 84 randomcolorsB = random(0, 255); 85 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 86 randomNum1 = random(0, 19); 87 randomNum2 = random(0, 19); 88 lcd.setCursor(0, 0); 89 lcd.print(msgs1[randomNum1]); 90 lcd.setCursor(0, 1); 91 lcd.print(msgs2[randomNum2]); 92 delay(3000); 93 lcd.clear(); 94 95 lcd.clear(); 96 randomcolorsR = random(0, 255); 97 randomcolorsG = random(0, 255); 98 randomcolorsB = random(0, 255); 99 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 100 randomNum1 = random(0, 19); 101 randomNum2 = random(0, 19); 102 lcd.setCursor(0, 0); 103 lcd.print(msgs1[randomNum1]); 104 lcd.setCursor(0, 1); 105 lcd.print(msgs2[randomNum2]); 106 delay(3000); 107 lcd.clear(); 108 109 110 randomcolorsR = (0, 255); 111 randomcolorsG = (0, 255); 112 randomcolorsB = (0, 255); 113 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 114 lcd.setCursor(6, 0); 115 lcd.print("fin"); 116 delay(900); 117 lcd.clear(); 118 119 randomcolorsR = (0, 255); 120 randomcolorsG = (0, 255); 121 randomcolorsB = (0, 255); 122 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 123 lcd.setCursor(1, 0); 124 lcd.write((uint8_t)0); 125 lcd.setCursor(3,0); 126 lcd.print("noah hellman"); 127 lcd.setCursor(6,1); 128 lcd.print("2016"); 129 delay(800); 130 131 132 } 133 else 134 { 135 noah(); 136 } 137} 138 139void noah() 140{ 141 randomcolorsR = (0, 255); 142 randomcolorsG = (0, 255); 143 randomcolorsB = (0, 255); 144 lcd.setRGB(randomcolorsR, randomcolorsG, randomcolorsB); 145 lcd.setCursor(0, 0); 146 lcd.print("Press for a grim"); 147 lcd.setCursor(2, 1); 148 lcd.print("4 line poem!"); 149} 150 151 152 153 154
Downloadable files
untitled
grove it all together!
untitled

Comments
Only logged in users can leave comments