Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(10, 9, 5, 4, 3, 2);
- int pingPin = 11;
- int echoPin= 12;
- byte smiley[8] = {
- B00000,
- B10001,
- B00000,
- B01110,
- B10001,
- B01110,
- B00000,
- };
- byte dick[8] {
- B01110,
- B10101,
- B01010,
- B01010,
- B01010,
- B11111,
- B10101,
- B11111,
- };
- byte penta[8] {
- B00100,
- B01010,
- B11111,
- B10001,
- B01110,
- B10101,
- B11011,
- };
- byte TMNT[8] {
- B00000,
- B00011,
- B00100,
- B11111,
- B01110,
- B01110,
- B10001
- };
- byte db1[8]{
- B00000,
- B01111,
- B11000,
- B10010,
- B10000,
- B10000,
- B10010,
- B11111
- };
- byte db2[8]{
- B00111,
- B11010,
- B01110,
- B00000,
- B10000,
- B10000,
- B10000,
- B11111
- };
- byte db3[8] {
- B11000,
- B01000,
- B00111,
- B00100,
- B00100,
- B11111,
- B00100,
- B11000
- };
- byte db4[8] {
- B00000,
- B00000,
- B10000,
- B10000,
- B00000,
- B10000,
- B10000,
- B00000,
- };
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
- lcd.print("hello, world!");
- }
- void loop() {
- long duration, inches, cm;
- int i;
- lcd.createChar(0, penta);
- lcd.begin(16, 2);
- lcd.write(byte(0));
- lcd.createChar(1, dick);
- lcd.setCursor(0,2);
- lcd.write(byte(1));
- lcd.createChar(2, TMNT);
- lcd.setCursor(1,0);
- lcd.write(byte(2));
- lcd.createChar(3, db1);
- lcd.createChar(4, db2);
- lcd.createChar(5, db3);
- lcd.createChar(6, db4);
- lcd.setCursor(3,0);
- lcd.write(byte(3));
- lcd.setCursor(4,0);
- lcd.write(byte(4));
- lcd.setCursor(5,0);
- lcd.write(byte(5));
- lcd.setCursor(6,0);
- lcd.write(byte(6));
- // pinMode(pingPin, OUTPUT);
- // digitalWrite(pingPin, LOW);
- // delayMicroseconds(2);
- // digitalWrite(pingPin, HIGH);
- // delayMicroseconds(5);
- // digitalWrite(pingPin, LOW);
- //
- // pinMode(pingPin, INPUT);
- // duration = pulseIn(pingPin, HIGH);
- //
- // inches = microsecondsToInches(duration);
- // cm = microsecondsToCentimeters(duration);
- lcd.display();
- delay(500);
- }
- long microsecondsToInches(long microseconds) {
- return microseconds / 74 / 2;
- }
- long microsecondsToCentimeters(long microseconds) {
- return microseconds / 29 / 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement