Used an ATTINY 2123 to directly control LED on picture frame. Flashes several patterns.

Code:

/*

Playing with generating and trapping interrupts using the Arduino and
an ATtiny2313.

Simple LED blinker, pin 9 will actually be connected to the ATtiny.

*/
byte led_pin16 = 16;
byte led_pin15= 15;
byte led_pin14= 14;
byte led_pin13= 13;
byte led_pin12 = 12;
byte led_pin11 = 11;
byte led_pin10 = 10;
byte led_pin9= 8;
byte led_pin8 = 9;
byte led_pin7 = 7;
byte led_pin6= 6;
byte led_pin5= 5;
byte led_pin4 = 4;
byte led_pin3= 3;
byte led_pin2= 2;



void setup() {
// put your setup code here, to run once:
pinMode(led_pin16, OUTPUT);
pinMode(led_pin15, OUTPUT);
pinMode(led_pin14, OUTPUT);
pinMode(led_pin13, OUTPUT);
pinMode(led_pin12, OUTPUT);
pinMode(led_pin11, OUTPUT);
pinMode(led_pin10, OUTPUT);
pinMode(led_pin9, OUTPUT);
pinMode(led_pin8, OUTPUT);
pinMode(led_pin7, OUTPUT);
pinMode(led_pin6, OUTPUT);
pinMode(led_pin5, OUTPUT);
pinMode(led_pin4, OUTPUT);
pinMode(led_pin3, OUTPUT);
pinMode(led_pin2, OUTPUT);


}
void loop() {

insequence();
steps();
circlesequence();
circleback();
randomblink();
}

void randomblink() {
int j=0;
int randNumber=0;
int randNumber1=0;
for (j=1;j<=25;j++){
randNumber = random(2,17);
randNumber1 = random(2,17);
digitalWrite(randNumber, HIGH);
delay(25); // wait for a second
digitalWrite(randNumber, LOW);
delay(50); // wait for a second
digitalWrite(randNumber1, HIGH);
delay(25); // wait for a second
digitalWrite(randNumber1, LOW);
delay(50); // wait for a second
}
delay(50);
}


void insequence() {

int i=0;
int j=0;
for (j=1;j<=4;j++){
for (i=1;i<=16;i++){
digitalWrite(i, HIGH);
delay(50);
digitalWrite(i, LOW);
delay(50);}
for (i=16;i>0;i--){
digitalWrite(i, HIGH);
delay(50);
digitalWrite(i, LOW);
delay(50);}}

}

void circleback() {

int i=0;
int j=0;
for (j=1;j<=4;j++){
for (i=16;i>0;i--){
digitalWrite(i, HIGH);
delay(50);
digitalWrite(i, LOW);
delay(50);}}

}

void circlesequence() {

int i=0;
int j=0;
for (j=1;j<=4;j++){
for (i=1;i<=16;i++){
digitalWrite(i, HIGH);
delay(25);
digitalWrite(i, LOW);
delay(25);}}

}

void steps() {
// put your main code here, to run repeatedly:
int i=0;
int j=0;
for (j=1;j<=4;j++){
for (i=1;i<=14;i=i+2){
digitalWrite(i, HIGH);
digitalWrite(i+1, HIGH);
digitalWrite(i+2, HIGH);
digitalWrite(i+3, HIGH);

delay(50);
digitalWrite(i, LOW);
digitalWrite(i+1,LOW);
digitalWrite(i+2,LOW);
digitalWrite(i+3,LOW);

delay(50);}

}}

Views: 294

Comment

You need to be a member of GarageLab (arduino, electronics, robotics, hacking) to add comments!

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

Profile IconJiangbin ZHENG and Riszter István joined GarageLab (arduino, electronics, robotics, hacking)
Thursday
Profile Iconkaan and guner guvenc joined GarageLab (arduino, electronics, robotics, hacking)
May 22
Devang Rameshbhai Zalavadiya is now a member of GarageLab (arduino, electronics, robotics, hacking)
May 18
Profile Iconraj kumar, Raffaello Palandri and Jigga Boo joined GarageLab (arduino, electronics, robotics, hacking)
May 7
Profile IconGabriele D'Angelo, dale wolver, Ibrahim Aykut and 2 more joined GarageLab (arduino, electronics, robotics, hacking)
May 5
Profile IconJaschaSaurus Rex and Christian Mock joined GarageLab (arduino, electronics, robotics, hacking)
May 1
Igor Golov is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 27
Marco is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 24
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Thanks for the advice. I will persist with the code till I get it done. thanks once again."
Apr 18
Marcelo Rodrigues commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
""The output waveforms on oscilloscope for Hsync and Vsync and for that matter RGB pins are not…"
Apr 17
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Hi  Marcelo I am trying to make this code work with Attiny 44a operating @ 20 MHz. I have…"
Apr 17
Profile IconReal NOiseux, Muhammad Ali, bob v and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Apr 17
baiqian is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 10
Profile IconDavide and Almas Amandossov joined GarageLab (arduino, electronics, robotics, hacking)
Apr 6
Profile Iconvamoalrenga and John Ferrell joined GarageLab (arduino, electronics, robotics, hacking)
Apr 3
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Yes, please share your progress here. Thanks and good"
Mar 27
FiniousFingers replied to FiniousFingers's discussion New to group
"Thanks, good to know someone is out there. I will be…"
Mar 27
Edward Evans replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Have you moved forward with any action?  I would be interested in discussing your…"
Mar 27
Marcelo Rodrigues replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Ed, No, they didn't deliver yet.  :( Good luck for us all."
Mar 23
Profile IconWesenachin Asfaw and Muhammad Basil joined GarageLab (arduino, electronics, robotics, hacking)
Mar 23

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service