Here i will show you how to interface a 7 segment LED
display with GR-Sakura (Arduino UNO compatible).
I have used LT543 Common Cathode display. Common Cathode LED’s
(around Rs.10) are cheaper than Common Anode (around Rs.30).
Circuit Diagram:
The resistors i used are of 1k ohm. 3rd and 8th pin goes to ground.
CountDown from 9 to 0:
Code:
#include<rxduino.h>
byte seven[12][7] = { { 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
{ 1,1,1,1,0,0,1 }, // = 3
{ 0,1,1,0,0,1,1 }, // = 4
{ 1,0,1,1,0,1,1 }, // = 5
{ 1,0,1,1,1,1,1 }, // = 6
{ 1,1,1,0,0,0,0 }, // = 7
{ 1,1,1,1,1,1,1 }, // = 8
{ 1,1,1,1,0,1,1 }, // = 9
};
int pins[10]={30,31,32,33,7,6,5,4};
int main()
{
static int i=9,j;
pinMode(30,
OUTPUT);
pinMode(31, OUTPUT);
pinMode(32, OUTPUT);
pinMode(33, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
delay(100);
digitalWrite(4,1);
while(1)
{
if(i<0)
{
i=9;
}
else
{
for(j=0;j<7;j++)
{
digitalWrite(pins[j],seven[i][j]);
}
delay(1000);
i--;
}
}
}
No comments:
Post a Comment