|
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int readkey;
int music=0;
void setup() {
lcd.begin(16, 2);
lcd.print("Welcome to Play");
}
void loop() {
lcd.setCursor(0, 1);
if(music<0) music=20;
lcd.print("Select ");
lcd.println(music);
lcd.print(" song");
readkey=analogRead(0);
if (readkey<50) { //
lcd.clear();
lcd.print("Music player");
delay(500);
}
else if(readkey<195) { //UP
lcd.clear();
music=music+1;
if(music>20) music=0;
lcd.print("Choosing music");
delay(500);
}
else if(readkey<380) { //Down
lcd.clear();
music=music-1;
lcd.print("Choosing music");
delay(500);
}
else if(readkey<790) { //
lcd.clear();
lcd.print("The music stops");
delay(500);
}
}
顯示出來的music值後面會有怪怪字 求解如何用掉 |
|