i am making a timing device for interval training i have done the timer 7 seg led and the buzzer but just need to add an on off switch basically any help is appreciated im fairly new to this
Moderators note: used code=c tags
C:
int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(1, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
//0
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,LOW); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//1
digitalWrite(pinA,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,LOW); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
//2
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//3
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
//4
digitalWrite(pinA,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//5
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
//6
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // wait for a second
delay(1000);
//7
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,LOW); // wait for a second
delay(1000);
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
//8
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//9
digitalWrite(pinA,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinB,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinC,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinD,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinE,LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinF,HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(pinG,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
//buzzer
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(250); // wait for a second
}
Last edited by a moderator: