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 Iconjames essien and Chow HP joined GarageLab (arduino, electronics, robotics, hacking)
Friday
Profile IconPerry Duvall, Irayya Mathad and wiley milam joined GarageLab (arduino, electronics, robotics, hacking)
Thursday
Profile IconAlan Powell and Chuck Nolan joined GarageLab (arduino, electronics, robotics, hacking)
Feb 9
Profile Iconpavan lakhe and Olive Liao joined GarageLab (arduino, electronics, robotics, hacking)
Feb 6
pin is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 3
Valcke Marc updated their profile
Feb 2
Bede Domokos is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 1
Profile IconToshiyuki Akashi and Valcke Marc joined GarageLab (arduino, electronics, robotics, hacking)
Jan 31
korte is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 30
Profile IconRobert Broedel, Al calaguin and Allan joined GarageLab (arduino, electronics, robotics, hacking)
Jan 26
HUZEFA ESSAJI is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 20
karthikeyan is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 19
Lou Rabinski is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 18
iftekhar Mobin is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 16
Profile IconLeicester Hibbert and Michael Young joined GarageLab (arduino, electronics, robotics, hacking)
Jan 9
Profile IconThorsten Schwarz and Dana Custer joined GarageLab (arduino, electronics, robotics, hacking)
Jan 2
Aqeel munir updated their profile
Dec 31, 2016
Todd Enger updated their profile
Dec 29, 2016
FRANK KWABENA is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 28, 2016
Ayhan Chaplan commented on GarageLab's blog post How to use a Peltier with Arduino
"Hi! Will this setup work with a 3,8V / 2,5A Peltier element? Or do I have to reduce the resistance…"
Dec 26, 2016

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service