Arduino、PIRセンサー、LCD 16 * 2を使って真実や挑戦ゲームをデザインしたいと思います。無作為にブール値を選んでください(Arduino LCD)
私は文をランダムに出すために別のコードを使用しようとしましたが、動作しません。それはランダムに出て止まらない。
すべての文章が長いため、私はブール値を選択します。私の文章をうまく表示することができます。今、文章はランダムに出てきますが、重なり合って停止しません。 :(
これはコードです:。。。
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int calibTime = 10;
int pirPin = 13;
boolean x = false;
boolean a = false;
boolean b = false;
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(" Truth or Dare? ");
lcd.setCursor(0, 1);
lcd.print("Touch to choose");
pinMode(pirPin, INPUT);
digitalWrite(pirPin, LOW);
}
void loop() {
if (x == true){
x = random(a=true,b=true);
}
if (a == true) {
lcd.setCursor(0, 0);
lcd.print("What is your");
lcd.setCursor(0, 1);
lcd.print("favor song?");
}
if (b == true) {
lcd.setCursor(0, 0);
lcd.print("asfsf");
lcd.setCursor(0, 1);
lcd.print("ujhfhgfyftry?");
}
if (digitalRead(pirPin) == HIGH) {
Serial.println("----------------------------");
Serial.println("** ALARM! MOTION DETECTED **");
Serial.println("----------------------------");
Serial.println("");
//int t = random(0, (sizeof(vors)/2));
x = true;
//return;
lcd.clear();
delay(1000);
}
if (digitalRead(pirPin) == LOW) {
!x;
}
}
[問題を小さなものに分割](http://happycoding.io/tutorials/how-to/program)できますか?問題を特定することはできますか? –
またこれはProcessing言語と関係がありますか?それは処理コードですか、それともArduinoコードですか? –