左,中,右骰子

时间:2019-03-05 04:17:13

标签: arduino

我去上传它,并且不断出现此错误:

Arduino: 1.8.8 (Windows 10), TD: 1.45, Board: "Arduino Nano, ATmega328P"

LEFT_RIGHT__CENTER:4:20: error: expected ',' or ';' before 'C'

 char letters = 'L' 'C' 'R';

                    ^

exit status 1
expected ',' or ';' before 'C'

#include <LiquidCrystal.h>
LiquidCrystal lcd (8, 9, 4, 5, 6, 7);
#include <stdlib.h>
char letters = 'L' 'C' 'R';
int n = rand() % letters;
    // define some values used by the panel and buttons
    int lcd_key     = 0;
    int adc_key_in  = 0;
  #define btnRIGHT  0
  #define btnUP     1
  #define btnDOWN   2
  #define btnLEFT   3
  #define btnSELECT 4
  #define btnNONE   5
    // read the buttons
    int read_LCD_buttons() {
      adc_key_in = analogRead(0);      // read the value from the sensor
      // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
      // we add approx 50 to those values and check to see if we are close
      //if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
      // For V1.1 us this threshold

      if (adc_key_in > 1000) { return btnNONE; }

      // For V1.0 comment the other threshold and use the one below:

      if (adc_key_in < 50)   { return btnRIGHT; }

      if (adc_key_in < 195)  { return btnUP; }

      if (adc_key_in < 380)  { return btnDOWN; }

      if (adc_key_in < 555)  { return btnLEFT; }

      if (adc_key_in < 790)  { return btnSELECT; }

      return btnNONE;  // when all others fail, return this...
    }
void setup() {
  lcd.begin(16, 2);              // start the library
  lcd.setCursor(0, 0);
  lcd.print("press select to dice"); // print a simple message
  randomSeed (analogRead (1));
}
void loop(){
lcd_key = read_LCD_buttons();  // read the buttons

    if(lcd_key == btnSELECT) {
        lcd.clear();
        lcd.setCursor(2, 0);
        lcd.print(printf("<%c>",n));
        lcd.setCursor(8, 0);
        lcd.print(printf("<%c>",n));
        lcd.setCursor(14,0);
        lcd.print(printf("<%c>",n));
    }
        analogRead(lcd_key == btnSELECT);
        delay(50);
        analogRead(lcd_key == btnSELECT);
        delay(50); 
}

我希望能够在LCD屏幕上的指定位置随机生成字母(每个字母不同)

0 个答案:

没有答案
相关问题