Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Week0/Aashvi_week0_attendance.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// https://www.tinkercad.com/things/dAwwuQHcmGp-aashvis-week0-attendance?sharecode=undefined

const int pot1Pin = A0;
const int pot2Pin = A1;

const int buzzerPins[3] = {2, 3, 4};
const int ledPins[5] = {5, 6, 7, 8, 9};

int currentLED = 0;
unsigned long previousMillis = 0;
int ledDelay = 200;

void setup() {
for (int i = 0; i < 3; i++) {
pinMode(buzzerPins[i], OUTPUT);
}
for (int i = 0; i < 5; i++) {
pinMode(ledPins[i], OUTPUT);
}
}

void loop() {
int pot1Value = analogRead(pot1Pin);
for (int i = 0; i < 3; i++) {
digitalWrite(buzzerPins[i], LOW);
}

if (pot1Value <= 341) {
digitalWrite(buzzerPins[0], HIGH);
} else if (pot1Value <= 682) {
digitalWrite(buzzerPins[1], HIGH);
} else {
digitalWrite(buzzerPins[2], HIGH);
}

int pot2Value = analogRead(pot2Pin);
ledDelay = map(pot2Value, 0, 1023, 100, 1000);

unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= ledDelay) {
previousMillis = currentMillis;

for (int i = 0; i < 5; i++) {
digitalWrite(ledPins[i], LOW);
}

digitalWrite(ledPins[currentLED], HIGH);
currentLED = (currentLED + 1) % 5;
}
}