#include <Wire.h>
#include <LiquidCrystal.h>
#include <LCDKeypad.h>
//define keycode for LCD push button
#define None 0
#define Select 1
#define Left 2
#define Up 3
#define Down 4
#define Right 5
LiquidCrystal lcd(8,9,4,5,6,7);
LCDKeypad keypad;
//define pin name
#define diy_pwm A2
#define pwm 3
#define dir 2
#define pot A1
void setup(){
lcd.begin (16,2);
lcd.clear();
pinMode(pwm,OUTPUT);
pinMode(dir,OUTPUT);
pinMode(diy_pwm,OUTPUT);
pinMode(pot,INPUT);
}
void loop(){
int localkey;
int pwm_value;
int reading=0;
int prev_reading = 0;
int output = 0;
lcd.setCursor(0,0);lcd.print("PWM:");
lcd.print(output);
lcd.setCursor(0,1);
lcd.print("DIR:");
lcd.print(digitalRead(dir));
while(1){
localkey = keypad.getKey();
if(localkey=Left){
digitalWrite(dir,digitalRead(dir));
lcd.setCursor(0,1);
lcd.print("DIR:");
lcd.print(digitalRead(dir));
delay(200);
}
reading=0;
for(int i=0; i<5; i++)
reading+=analogRead(pot);
reading/=5;
output=reading*0.2493;
if (reading!=prev_reading){
lcd.print("");
lcd.setCursor(0,0);
lcd.print("PWM:");
lcd.print(output);
prev_reading=reading;
}
analogWrite(pwm,output);
}
}
someone please help me SOS! i've tried everything but the error still pops up. i don't know what is the problem. I'm trying to drive a motor and control the speed by pressing the buttons on the keypad shield. i cannot get the input from the keypad shield SOS!!