Hello guys,
I have bought this module: RepRapDiscount Full Graphic Smart Controller - RepRap
and I want to use it for other purpose instand of 3D printers.
I've managed to access to the beeper and the 128*64 LCD and the rotary button,
But I was unable to detect right\left movement on the rotary, I have attached Rotary encoder to arduino before this way.
Using the code that i've wrote:
#include <Wire.h>
#define inputROTARYBUTTON 12
#define inputRIGHT 10
#define inputLEFT 11
#define BUTTONCLICKED 0
int counter = 0;
int currentState;
int previousState;
bool ButtonClicked(int id){
return (digitalRead(id) == BUTTONCLICKED);
}
void setup() {
Serial.begin (9600);
// Set encoder pins as inputs
pinMode (inputRIGHT,INPUT);
pinMode (inputLEFT,INPUT);
pinMode(inputROTARYBUTTON, INPUT_PULLUP);
digitalWrite(inputROTARYBUTTON, HIGH);
// Setup Serial Monitor
previousState = digitalRead(inputRIGHT);
}
void loop() {
delay(10);
currentState = digitalRead(inputRIGHT);
if (currentState != previousState){
if (digitalRead(inputLEFT) != currentState) { //TURN RIGHT
counter --;
} else { //TURN LEFT
counter ++;
}
Serial.print("Value: ");
Serial.println(counter);
}
previousState = currentState;
if(ButtonClicked(inputROTARYBUTTON) == 1){
Serial.println("clicked!");
}
}
according to "RepRap ..... smart controller" schematic I've plugged 3,5PINS on EXP2 to pin 10,11 on Arduino, but its seem to be all the time as 'HIGH'.
how cam i fix it?