-
Notifications
You must be signed in to change notification settings - Fork 1
[DO NOT MERGE] 参考に #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,12 +29,8 @@ void setup() { | |
| mfrc522.PCD_DumpVersionToSerial(); | ||
| Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks...")); | ||
|
|
||
|
|
||
| display.clearDisplay();//一度初期化 | ||
| display.setTextSize(2);// 出力する文字の大きさ | ||
| display.setTextColor(WHITE);//出力する文字の色 | ||
| display.setCursor(0, 0);//カーソル位置の指定 | ||
| display.println("Nocard");// ディスプレイへ表示する文字列 | ||
| resetDisplay() | ||
| printlnText("Nocard", 2); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 目的は
今回は |
||
| display.display();//ディスプレイ情報の更新 | ||
|
|
||
|
|
||
|
|
@@ -47,17 +43,35 @@ void setup() { | |
|
|
||
|
|
||
| Message = "No mode"; | ||
| NUMBER = "000"; | ||
| NUMBER = 000; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 8行目で |
||
| } | ||
|
|
||
| void resetDisplay () { | ||
| display.clearDisplay(); // 一度初期化 | ||
| display.setCursor(0, 0); // 一度初期化 | ||
| display.setTextColor(WHITE); | ||
| } | ||
|
|
||
| void printText (String text, int textSize) { | ||
| display.setTextSize(textSize) | ||
| display.print(text) | ||
| } | ||
|
|
||
| void printlnText (String text, int textSize) { | ||
| display.setTextSize(textSize) | ||
| display.println(text) | ||
| } | ||
|
|
||
| void loop() { | ||
| digitalWrite(3, HIGH); //初期設定 | ||
| digitalWrite(4, LOW); //初期設定 | ||
| noTone(6);//初期設定 | ||
| if ( ! mfrc522.PICC_IsNewCardPresent()) return;// Mifareカードの確認(新しいカードが無ければ終了し、loop関数を繰り返す) | ||
| if ( ! mfrc522.PICC_ReadCardSerial()) return;// Mifareカードのデータ読み込み(読み取れなければ終了し、loop関数を繰り返す) | ||
|
|
||
| if ( | ||
| ! mfrc522.PICC_IsNewCardPresent() || // Mifareカードのデータ読み込み | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 論理演算子を用いて簡潔に.見た目もよくなるし,loop関数で分岐する回数が半分になるので処理的にも優しくなりまする |
||
| ! mfrc522.PICC_ReadCardSerial()) { // Mifareカードの確認 | ||
| return; // どちらかを満たさない場合はloop関数を繰り返す | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
@@ -72,15 +86,11 @@ void loop() { | |
| Serial.println(strUID); | ||
|
|
||
|
|
||
| resetDisplay() | ||
|
|
||
| if ( strUID == UID ) { | ||
| display.clearDisplay();//一度初期化 | ||
| display.setCursor(0, 0);//一度初期化 | ||
| display.println("collect"); | ||
| display.setTextSize(1); | ||
| display.setTextColor(WHITE); | ||
| display.print("cardUID = "); | ||
| display.println(strUID); | ||
| printlnText("collect", 2); | ||
| printlnText("cardUID = " + strUID, 1); | ||
| display.display(); | ||
|
|
||
| tone(6, 1700); | ||
|
|
@@ -91,16 +101,9 @@ void loop() { | |
| delay(500); | ||
|
|
||
| blank(strUID); | ||
| } | ||
|
|
||
| if ( !(strUID == UID) ) { | ||
| display.clearDisplay();//一度初期化 | ||
| display.setCursor(0, 0);//一度初期化 | ||
| display.println("error!"); | ||
| display.setTextSize(1); | ||
| display.setTextColor(WHITE); | ||
| display.print("cardUID = "); | ||
| display.println(strUID); | ||
| } else { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| printlnText("error!", 2); | ||
| printlnText("cardUID = " + strUID, 2); | ||
| display.display(); | ||
|
|
||
| Serial.println("else"); | ||
|
|
@@ -109,11 +112,8 @@ void loop() { | |
| tone(6, 500); | ||
| delay(1000); | ||
|
|
||
| display.clearDisplay();//一度初期化 | ||
| display.setTextSize(2);// 出力する文字の大きさ | ||
| display.setTextColor(WHITE);//出力する文字の色 | ||
| display.setCursor(0, 0);//カーソル位置の指定 | ||
| display.println("Nocard");// ディスプレイへ表示する文字列 | ||
| resetDisplay() | ||
| printlnText("Nocard", 2); | ||
| display.display();//ディスプレイ情報の更新 | ||
| } | ||
| } | ||
|
|
@@ -128,39 +128,29 @@ void blank(String strUID) { | |
| pointAdd = digitalRead(A2); | ||
| submit = digitalRead(A3); | ||
|
|
||
| display.clearDisplay();//一度初期化 | ||
| display.setTextSize(2);// 出力する文字の大きさ | ||
| display.setCursor(0, 0);//カーソル位置の指定 | ||
| display.println(Message);// ディスプレイへ表示する文字 | ||
| display.setTextSize(1);// 出力する文字の大きさ | ||
| display.print("NUMBER = "); | ||
| display.setTextSize(2);// 出力する文字の大きさ | ||
| display.println(NUMBER); | ||
| resetDisplay() | ||
| printlnText(Message, 2); | ||
| printText("NUMBER = ", 1); | ||
| printlnText(NUMBER, 2); | ||
| display.display();//ディスプレイ情報の更新 | ||
| delay(300); | ||
|
|
||
|
|
||
| if ( mode <= 85 ) { | ||
| Message = "Reset"; | ||
| } | ||
|
|
||
|
|
||
| if ( 85 < mode && mode < 170 ) { | ||
| } else if ( 85 < mode && mode < 170 ) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Message = "Point"; | ||
| } | ||
|
|
||
|
|
||
| if ( 170 <= mode ) { | ||
| } else if ( 170 <= mode ) { | ||
| Message = "GameT"; | ||
| } | ||
|
|
||
|
|
||
| if (pointDeduct == 0) { | ||
| NUMBER = NUMBER - 10; | ||
| NUMBER -= 10; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| if (pointAdd == 0) { | ||
| NUMBER = NUMBER + 10; | ||
| NUMBER += 10; | ||
| } | ||
|
|
||
| if (submit == 0) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
何回も初期化すると思うので,画面の初期化処理を関数にする.関数の内容は