// constants won't change. They're used here to set pin numbers:
const int butUp = 8; // the number of the pushbutton pin
const int butDn = 10;
const int ledPin = 9; // the number of the LED pin
// variables will change:
int butUpState = 0; // variable for reading the pushbutton status
int butDnState = 0; // variable for reading the pushbutton status
int var = 0;
void setup() {
// put your setup code here, to run once:
// initialize the LED pin as an output:
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(butUp, INPUT);
pinMode(butDn, INPUT);
}
void loop() {
//PWM, enter setup, state machine
//
// put your main code here, to run repeatedly:
// read the state of the pushbutton value:
butUpState = digitalRead(butUp);
butDnState = digitalRead(butDn);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (butUpState == HIGH) {
digitalWrite(ledPin, HIGH); // turn LED on:
Serial.println("UP");
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
delay(20);
//////////////////////
////state machine
//////////////////////
//idle - pmw light ramp upd and down
//go up - fast blink .:* ; M1234 up
//go down - fast blink *:. ; M1234 dn
//adjust1 - 1 blink
//a1 up - pres/press+hold - M1 up
//a1 dn - pres/press+hold - M1 dn
//adjust2 - 2 blinks
//adjust3
//adjust4
//
//
//long press both - enter adjust mode, adjust1
//short press both - adjust1->adjust2, modulo 4
//long press both again - leave adjust mode
//short press up/dn - move up/dn
switch (var) {
case 1:
//do something when var equals 1
break;
case 2:
//do something when var equals 2
break;
default:
// if nothing else matches, do the default
// default is optional
break;
}
}