..
လိုအပ်သောကုဒ်များကို အောက်တွင် ဒေါင်းယူပါ..
မူရင်းလင့်ခ်သို့Simple Arduino programming code to make 150 led light set. You will need Arduino Nano controller.
Download Arduino IDE at
https://www.arduino.cc/en/Main/Software
/************************************************************************************************
* This program control 150 LED light. All rows are + and all columns are - .
* 6 set columns (5 columns each) are connected as one.
* Program control 5 rwos and 6 sets of columns(5 columns each).
* Program version 150.5.5
* created on January 2017.
* Created by Myint Lwin
**************************************************************************************************/
//setup row pin numbers(long pin from LED +)
int rows = 5;
int row[] = {2,3,4,5,6};
//setup col pin number(Short pin from LED -)
int cols = 5;
int col[] = {A0,A1,A2,A3,A4};
int delayTime = 50;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin for row as an output.
for(int i=0; i<rows; i++) pinMode(row[i], OUTPUT);
// initialize digital pin for column as an output.
for(int i=0; i<cols; i++) pinMode(col[i], OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
f1(6); // all columns on. ligh on and off by rows.
f2R(10,60);
f2L(10, 60);
for(int i=0; i<rows; i++) { f3R(5,i,delayTime); f3(3,delayTime); }
for(int i=0; i<rows; i++) { f4R(5,i,delayTime); f4(3,delayTime); }
for(int i=0; i<rows; i++) { f5R(5,i,delayTime); f5(3,delayTime); }
f6(15);
}
void rowOn(int r) {
if(r>(rows-1)) digitalWrite(row[r-rows], HIGH);
else if(r<0) digitalWrite(row[r+rows] , HIGH);
else digitalWrite(row[r], HIGH);
}
void rowOff(int r) {
if(r>(rows-1)) digitalWrite(row[r-rows], LOW);
else if(r<0) digitalWrite(row[r+rows] , LOW);
else digitalWrite(row[r], LOW);
}
void colOn(int c){
if(c>(cols-1)) digitalWrite(col[c-cols], LOW);
else if(c<0) digitalWrite(col[c+cols] , LOW);
else digitalWrite(col[c], LOW);
}
void colOff(int c){
if(c>(cols-1)) digitalWrite(col[c-cols], HIGH);
else if(c<0) digitalWrite(col[c+cols] , HIGH);
else digitalWrite(col[c], HIGH);
}
void allRowOn() {
// Set all row HIGH(Turn all rows ON)
for(int k=0; k<rows; k++) rowOn(k);
}
void allRowOff() {
// Set all row LOW(Turn all rows OFF)
for(int i=0; i<rows; i++) rowOff(i);
}
void allColOn() {
//set all columns HIGH (turn All Columns OFF)
for(int i=0; i<cols; i++) colOn(i);
}
void allColOff() {
//set all columns LOW (turn All Columns ON)
for(int i=0; i<cols; i++) colOff(i);
}
void off() {
allRowOff();
allColOff();
}
void rOn(int start, int last) {
for(int k=start; k<(last+1); k++){
rowOn(k);
}
}
void cOn(int start, int last) {
for(int i=start; i<(last+1); i++){
colOn(i);
}
}
void f1(int n) {
off();
allColOn();
for(int count=0; count < n; count++) {
for(int k=0; k<rows; k++) {
rowOn(k);
delay(delayTime+60);
}
for(int i=0; i<rows; i++) {
rowOff(i);
delay(delayTime+60);
}
}
}
void f2b(int i,int s) {
for(int j=0; j<s; j++) {
rowOn(0); rowOn(1); rowOn(2); colOn(i); colOn(i+1); delay(1); off();
rowOn(3); rowOn(4); colOn(i); colOn(i+1); delay(1); off();
}
}
void f2R(int n, int s) {
off();
for(int count=0; count < n; count++){
for(int i=0; i<cols; i++) {
f2b(i, s);
}
}
}
void f2L(int n, int s) {
off();
for(int count=0; count < n; count++){
for(int i=(cols-1); i>-1; i--) {
f2b(i, s);
}
}
}
void f3b(int i, int k, int s) {
for(int j=0; j < s; j++) {
allColOn(); rowOn(k); rowOn(k+1); rowOn(k+4); delay(1); off();
allColOn(); delay(1); off();
rowOn(k+2); rowOn(k+3); colOn(i); delay(1); off();
}
}
void f3(int n, int s) {
for(int count=0; count < n; count++) {
for(int k=0; k<rows; k++) {
f3b(0,k,s);
}
}
}
void f3R(int n, int k, int s){
for(int count=0; count < n; count++){
for(int i=0; i<cols; i++) {
f3b(i,k,s);
}
}
}
void f3L(int n, int s){
for(int count=0; count < n; count++){
for(int i=(cols-1); i>-1; i--) {
f3b(i,s,0);
}
}
}
void f4b(int i, int k, int s) {
for(int j=0; j<s; j++) {
allColOn(); rowOn(k+2); rowOn(k+3); delay(1); off();
rowOn(k); rowOn(k+1); rowOn(k+4); colOn(i); delay(1); off();
}
}
void f4(int n, int s) {
for(int count=0; count < n; count++) {
for(int k=0; k<rows; k++) {
f4b(0,k,s);
}
}
}
void f4R(int n, int k, int s){
for(int count=0; count < n; count++){
for(int i=0; i<cols; i++) {
f4b(i,k,s);
}
}
}
void f4L(int n, int k, int s){
for(int count=0; count < n; count++){
for(int i=(cols-1); i>-1; i--) {
f4b(i,k,s);
}
}
}
void f5b(int i, int k, int s) {
for(int j=0; j<s; j++) {
allColOn(); rowOn(k); rowOn(k+1); rowOn(k+3); delay(1); off();
rowOn(k+2); rowOn(k+4); colOn(i); delay(1); off();
}
}
void f5(int n, int s) {
for(int count=0; count < n; count++) {
for(int k=0; k<rows; k++) {
f5b(0,k,s);
}
}
}
void f5R(int n, int k, int s){
for(int count=0; count < n; count++){
for(int i=0; i<cols; i++) {
f5b(i,k,s);
}
}
}
void f5L(int n, int k, int s){
for(int count=0; count < n; count++){
for(int i=(cols-1); i>-1; i--) {
f5b(i,k,s);
}
}
}
void f6(int n) {
allRowOff();
allColOn();
for(int count=0; count < n; count++) {
for(int k=0; k < rows; k++) {
rowOn(k); delay(delayTime-50); allRowOff();
}
}
}
copyကူးထားတာကို ဘယ်ထဲမှာပြန်ထည့်ရတာလဲဗျ
ReplyDelete