//WOKWI demo
//Start up plotter and change dip switch to change delay in loop
//switch is read as a binary, least significant bits on the right
#include <TM1637Display.h>
float myDelay = 0;
#define CLK_PIN A4
#define DIO_PIN A5
TM1637Display myDisplay = TM1637Display(CLK_PIN, DIO_PIN);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
myDisplay.setBrightness(10) ;
pinMode(LED_BUILTIN, OUTPUT);
for (int i = 2; i < 10; i++){
pinMode(i, INPUT_PULLUP);
}
}
void loop() {
// put your main code here, to run repeatedly:
float fIndex=0;
do {
myDelay = 0;
for (int i = 2; i < 10; i++){
myDelay = !digitalRead(i)*pow(2,(i-2)) + myDelay;
}
myDisplay.showNumberDec(myDelay);
fIndex = fIndex + 0.1;
Serial.println(sin(fIndex));
if (sin(fIndex) > 0) {digitalWrite(LED_BUILTIN, HIGH);}
if (sin(fIndex) < 0) {digitalWrite(LED_BUILTIN, LOW);}
delay(myDelay);
} while(true);
}