- 12 LEDs
- Computer
- Arduino compiler
- Arduino cable
- Alot of wires
And of course my sketch:
///////////////////////////////////////////////////////////
// c0d3d by Kirill Kozlov 2013 //
// Binary clock (Robatics lessons) //
///////////////////////////////////////////////////////////
// v0.2 - Fully workable //
///////////////////////////////////////////////////////////
int led13 = 0;
int led12 = 0;
int led11 = 0;
int led10 = 0;
int led9 = 0;
int led8 = 0;
int led7 = 0;
int led6 = 0;
int led5 = 0;
int led4 = 0;
int led3 = 0;
int led2 = 0;
int secondsleft = 0;
int minutesleft = 0;
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
}
void loop()
{
if(led8 == 0)
{
digitalWrite(8, HIGH);
led8 = 1;
goto secend;
}
else
{
digitalWrite(8, LOW);
led8 = 0;
}
if(led9 == 0)
{
digitalWrite(9, HIGH);
led9 = 1;
goto secend;
}
else
{
digitalWrite(9, LOW);
led9 = 0;
}
if(led10 == 0)
{
digitalWrite(10, HIGH);
led10 = 1;
goto secend;
}
else
{
digitalWrite(10, LOW);
led10 = 0;
}
if(led11 == 0)
{
digitalWrite(11, HIGH);
led11 = 1;
goto secend;
}
else
{
digitalWrite(11, LOW);
led11 = 0;
}
if(led12 == 0)
{
digitalWrite(12, HIGH);
led12 = 1;
goto secend;
}
else
{
digitalWrite(12, LOW);
led12 = 0;
}
if(led13 == 0)
{
digitalWrite(13, HIGH);
led13 = 1;
goto secend;
}
else
{
digitalWrite(13, LOW);
led13 = 0;
}
secend:
secondsleft++;
if(secondsleft == 60)
{
minutesleft++;
secondsleft = 0;
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
led13 = 0;
led12 = 0;
led11 = 0;
led10 = 0;
led9 = 0;
led8 = 0;
if(led2 == 0)
{
digitalWrite(2, HIGH);
led2 = 1;
goto minend;
}
else
{
digitalWrite(2, LOW);
led2 = 0;
}
if(led3 == 0)
{
digitalWrite(3, HIGH);
led3 = 1;
goto minend;
}
else
{
digitalWrite(3, LOW);
led3 = 0;
}
if(led4 == 0)
{
digitalWrite(4, HIGH);
led4 = 1;
goto minend;
}
else
{
digitalWrite(4, LOW);
led4 = 0;
}
if(led5 == 0)
{
digitalWrite(5, HIGH);
led5 = 1;
goto minend;
}
else
{
digitalWrite(5, LOW);
led5 = 0;
}
if(led6 == 0)
{
digitalWrite(6, HIGH);
led6 = 0;
goto minend;
}
else
{
digitalWrite(6, LOW);
led6 = 0;
}
if(led7 == 0)
{
digitalWrite(7, HIGH);
led7 = 0;
goto minend;
}
else
{
digitalWrite(7, LOW);
led7 = 0;
}
}
minend:
if(minutesleft == 60)
{
minutesleft = 0;
secondsleft = 0;
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(2, LOW);
led13 = 0;
led12 = 0;
led11 = 0;
led10 = 0;
led9 = 0;
led8 = 0;
led7 = 0;
led6 = 0;
led5 = 0;
led4 = 0;
led3 = 0;
led2 = 0;
}
delay(1000);
}
Upload and enjoy!
No comments:
Post a Comment