#include <EventButton.h>
//declare our digital input pins on the board
int hbp2 = 2;
int upshiftPin = 8;
int downshiftPin = 5;
//this is the value of the input from the switches
int Up = 0;
int Down = 0;
int Hbmod=0;
//boolean keeping track of last state of button
boolean old_HB_state = false;
boolean old_Up_state = false;
boolean old_Down_state = false;
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);
while (!Serial1) {
delay(10); // wait for serial port to connect. Needed for native USB
}
// Now you can safely print message:
Serial1.println("Hello, Serial Monitor!");
pinMode(upshiftPin, INPUT_PULLUP);
pinMode(downshiftPin, INPUT_PULLUP);
pinMode(hbp2, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
delay(1000); // this speeds up the simulation
Up = digitalRead(upshiftPin);
Down = digitalRead(downshiftPin);
Hbmod = digitalRead(hbp2);
old_HB_state = Hbmod;
String msg = "Handbrake Mode: "+ String(Hbmod)+", Upshift: "+String(Up)+", Downshift: "+String(Down);
Serial1.println(msg);
/*
if(Hbmod!=HIGH && Down!=HIGH)
{
Serial1.println("Handbrake Pulled!!");
}else if(Hbmod==HIGH && Up!=HIGH){
Serial1.println("Upshift (add gear)!!"+Up);
}
else if(Hbmod==HIGH && Down!=HIGH){
Serial1.println("Downshift (subtract gear)!!"+Down);
}
else{
Serial1.print("");
};
*/
}
void handbrake(boolean newstate){
if(!old_HB_state && newstate){
old_HB_state=true;
Serial1.println("Handbrake Mode On");
}else if(old_HB_state && !newstate){
old_HB_state=false;
Serial1.println("Handbrake Mode Off");
}
}