Advertisement
MUstar

IoT 아두이노 0609 - LCD No.2

Jun 9th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. int pin_LCD_DATA[8] = {A8,A9,A10,A11,A12,A13,A14,A15};
  4. int pin_LCD_CTRL[3] = {A5,A6,A7};
  5. LiquidCrystal lcd(A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15);
  6. int sw[6] = {20,22,24,26,28,30}; // Switch
  7. void setup() {
  8.   lcd.begin(16,2);
  9.   pinMode(sw,INPUT_PULLUP);
  10.  
  11. }
  12. void loop() {
  13.    boolean pw = false;
  14.    int w=0 , h=0;
  15.    while(1){
  16.    lcd.clear();
  17.    if(digitalRead(sw[1]) == HIGH) {w=0;delay(100);} //UP
  18.    if(digitalRead(sw[2]) == HIGH) {w=1;delay(100);} //DOWN
  19.    if(digitalRead(sw[3]) == HIGH) {if(h<=0){continue;}h--;delay(100);} //LEFT
  20.    if(digitalRead(sw[4]) == HIGH) {if(h>=15){continue;}h++;delay(100);} //RIGHT
  21.    lcd.setCursor(h,w);
  22.    lcd.print("*");
  23.    delay(100);
  24.    }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement