This should be Working, But it isn't Arduino Starter Kit Crystal Ball


the button not anything. loaded example program , worked perfectly. checked code word word example, finding no differences. thing noticed when programs compiled used different amounts of memory. appreciate if can figure out , please excuse poor coding skills because i've been doing 5 hours.

code: [select]

#include <liquidcrystal.h>
liquidcrystal lcd(12, 11, 5, 4, 3, 2);
const int switchpin = 6;
int switchstate = 0;
int prevswitchstate = 0;
int reply;

void setup() {
  lcd.begin(16, 2);
  pinmode(switchpin, input);
  lcd.print("ask the");
  lcd.setcursor(0,1);
  lcd.print("crystal ball!");
}

void loop() {
  switchstate = digitalread(switchpin);
  if (switchstate != prevswitchstate){
   if(switchstate = low){
    reply = random(8);
    lcd.clear();
    lcd.setcursor(0, 0);
    lcd.print("the ball says:");
    lcd.setcursor(0, 1);
   
    switch (reply){
      case 0:
      lcd.print("yes");
      break;
     
      case 1:
      lcd.print("possibilities");
      break;
     
      case 2:
      lcd.print("good fortune");
      break;
     
      case 3:
      lcd.print("looking good");
      break;
     
      case 4:
      lcd.print("huh?");
      break;
     
       case 5:
       lcd.print("try again");
       break;
     
      case 6:
      lcd.print("no");
      break;
     
      case 7:
      lcd.print("impossible");
      break;
    }
   }
  }
  prevswitchstate = switchstate;
}

compare line in code original
code: [select]

    if (switchstate = low)

that assignment statement , not compare statement.


Arduino Forum > Using Arduino > Programming Questions > This should be Working, But it isn't Arduino Starter Kit Crystal Ball


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'