Ok so I now have figured out the 7 segment display. My next problem is that I need to make it so that if the display shows a certain number, pressing another button will cause 3 lights to flash at speeds that depend on the display. I think that I will need to use threading but I'm uncertain as to which approach to use. here is my code so far:
int switchPin = 10;
int button2 = 9;
int ledPin = 13;
int ledPin2 = 12;
int ledPin3 = 11;
int a = 0;
int b = 1;
int c = 2;
int d = 3;
int e = 4;
int f = 5;
int g = 7;
int Decimalpoint = 8;
void setup()
{
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(Decimalpoint, OUTPUT);
pinMode(button2, INPUT);
}
void one()
{
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
digitalWrite(Decimalpoint,HIGH);
}
void two()
{
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
digitalWrite(Decimalpoint,HIGH);
}
void three()
{
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(Decimalpoint,HIGH);
}
void four()
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
digitalWrite(Decimalpoint,HIGH);
}
void five()
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(Decimalpoint,HIGH);
}
void speed1()
{
if (digitalRead(switchPin) == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin2, HIGH);
delay(100);
digitalWrite(ledPin2, LOW);
delay(100);
digitalWrite(ledPin3, HIGH);
delay(100);
digitalWrite(ledPin3, LOW);
delay(100);
}
}
void speed2()
{
if (digitalRead(switchPin) == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
digitalWrite(ledPin2, HIGH);
delay(200);
digitalWrite(ledPin2, LOW);
delay(200);
digitalWrite(ledPin3, HIGH);
delay(200);
digitalWrite(ledPin3, LOW);
delay(200);
}
}
void speed3()
{
if (digitalRead(switchPin) == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
delay(300);
digitalWrite(ledPin2, HIGH);
delay(300);
digitalWrite(ledPin2, LOW);
delay(300);
digitalWrite(ledPin3, HIGH);
delay(300);
digitalWrite(ledPin3, LOW);
delay(300);
}
}
void speed4()
{
if (digitalRead(switchPin) == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(400);
digitalWrite(ledPin, LOW);
delay(400);
digitalWrite(ledPin2, HIGH);
delay(400);
digitalWrite(ledPin2, LOW);
delay(400);
digitalWrite(ledPin3, HIGH);
delay(400);
digitalWrite(ledPin3, LOW);
delay(400);
}
}
void speed5()
{
if (digitalRead(switchPin) == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
digitalWrite(ledPin2, HIGH);
delay(500);
digitalWrite(ledPin2, LOW);
delay(500);
digitalWrite(ledPin3, HIGH);
delay(500);
digitalWrite(ledPin3, LOW);
delay(500);
}
}
void loop()
{
for(int i=1; 1 <= i <= 5; i++)
{
switch(i)
{
case 1:
while(digitalRead(button2)==LOW){
one();
}
delay(100);
if (digitalRead(button2)==LOW) {
break;
}
case 2:
while(digitalRead(button2)==LOW){
two();
}
delay(100);
if (digitalRead(button2)==LOW) {
break;
}
case 3:
while(digitalRead(button2)==LOW){
three();
}
delay(100);
if (digitalRead(button2)==LOW) {
break;
}
case 4:
while(digitalRead(button2)==LOW){
four();
}
delay(100);
if (digitalRead(button2)==LOW) {
break;
}
case 5:
while(digitalRead(button2)==LOW){
five();
}
delay(100);
if (digitalRead(button2)==LOW) {
break;
}
}
}
}