Arduino Code 7 Segment Display
//Created by Simple Circuits
byte pin[] = {2, 3, 4, 5, 6, 7, 8, 9};//arduino pin array
int number[10][8] = {//number array
{0, 0, 0, 0, 0, 0, 0, 1},//0
{1, 1, 0, 0, 0, 1, 1, 1},//1
{0, 0, 1, 0, 0, 0, 1, 0},//2
{1, 0, 0, 0, 0, 0, 1, 0},//3
{1, 1, 0, 0, 0, 1, 0, 0},//4
{1, 0, 0, 0, 1, 0, 0, 0},//5
{0, 0, 0, 0, 1, 0, 0, 0},//6
{1, 1, 0, 0, 0, 0, 0, 1},//7
{0, 0, 0, 0, 0, 0, 0, 0},//8
{1, 1, 0, 0, 0, 0, 0, 0},//9
};
void setup() {
for (byte a = 0; a < 9; a++) {
pinMode(pin[a], OUTPUT);//define output pins
}
}
void loop() {
for (int a = 0; a < 10; a++) {
for (int b = 0; b < 9; b++) {
digitalWrite(pin[b], number[a][b]);//display numbers
}
delay(1000);//delay
}
}
Comments
Post a Comment