#include "SevSeg.h"
SevSeg sevseg;
const int switchPin1 = 22; // Replace with the actual pin number for the first switch
const int switchPin2 = 26; // Replace with the actual pin number for the second switch
const int switchPin3 = 30;
const int ledPin = 34;
void setup() {
// put your setup code here, to run once:
pinMode(switchPin1, INPUT_PULLUP);
pinMode(switchPin2, INPUT_PULLUP);
pinMode(switchPin3, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
byte numDigits = 1;
byte digitPins[] = {};
byte segmentPins[] = {4, 5, 6, 7, 8, 9, 10, 11};
bool resistorsOnSegments = true; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_CATHODE; // See README.md for options
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(100);
}
void loop() {
int switchState = getSwitchState();
sevseg.setNumber(switchState);
sevseg.refreshDisplay();
delay(100);
switch (switchState) {
case 1:
digitalWrite(ledPin, HIGH);
delay (1);
digitalWrite(ledPin, LOW);
break;
case 2:
// Mode 2: Add your code for mode 2
// ...
break;
// Add more cases for other modes as needed
// ...
default:
// Default case: Turn off the LED if none of the specific cases match
digitalWrite(ledPin, LOW);
break;
}
}
int getSwitchState() {
/* edit this function to read the state of the three switches
and return the correct decimal number associated with the
position of each switch.
For example, if all switches are off, this function should
return 0. If only the right most switch is on, this function
should return 1, and so forth.
*/
int switchState = 0;
switchState |= digitalRead(switchPin1) << 2;
switchState |= digitalRead(switchPin2) << 1;
switchState |= digitalRead(switchPin3);
// 0 0 0
// 1 0 0
// 0 1 0
return switchState;
}