Sorry i have looked as well as i can but i couldn't find an answer to this.. and i am a newbie so my question might sound or be worded wrong but thank you ahead of time for the help;
I want to make the status of "statinput" to print only when the "inputVal" has changed from the last recorded value ie: "lastVal".
int statinput = 2; //Digital Input for the motor status
int inVal; //Val palce holder
int lastVal= 0;
int inputVal =0;
void setup(){
Serial.begin(9600); //Opens com port
analogReference(INTERNAL1V1); // Referenances the internal voltage to make calculation for voltage
analogRead(0); //added to switch reference
pinMode(statinput, INPUT); //states the pin function as an input
}
void loop(){
{
int inputVal = digitalRead (statinput); //Reads the input from the motor transitor
Serial.print("#S|LOGTEST|["); //Gobetwino start LOGTEST command
if (inputVal == HIGH)// if the Digital input is high (5v)
{
Serial.print("Motor Status: ON "); // Prints out the motor on state
}
else
{
Serial.print("Motor Status: OFF "); //Prints out motor state if not = high
}
Serial.println("]#"); //ends Goberwino command
}
lastVal = inputVal;
can someone help please. I looked at the button example but i couldn't reproduce the results I wanted..