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

Related Videos

Comment

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

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

iftekhar Mobin is now a member of GarageLab (arduino, electronics, robotics, hacking)
9 hours ago
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
Profile IconAyhan Chaplan, Erva and Donna Carter joined GarageLab (arduino, electronics, robotics, hacking)
Dec 26, 2016
Galy Huang posted a discussion

Ubuntu on Firefly-RK3399

Firefly-RK3399 with dual-core Cortex-A72 and quad-core Cortex-A53, ARM® Mali-T860 MP4 quad-core…See More
Dec 20, 2016
Chase Rangel posted a discussion

What is the simplest way to control one brushless motor forward/reverse?

  Hello everyone I don't know much about this type of stuff had only a handful of RC cars.I've been…See More
Dec 12, 2016
Profile IconErving Howe, Chase Rangel, Werner Pretorius and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Dec 12, 2016
Frank Turner is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 9, 2016
Marcelo Rodrigues and swapnil are now friends
Dec 6, 2016
Marcelo Rodrigues replied to swapnil's discussion Tiny 85 based Thermometer
"Dear Swapnil, Since you don't have any experience with programming you should consider start…"
Dec 5, 2016
swapnil posted a discussion

Tiny 85 based Thermometer

Hi, can any one guide me how to make the tiny 85 based Thermometer which will glow the LED…See More
Dec 4, 2016
Spyros Svoronos is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 4, 2016
K Biju is now a member of GarageLab (arduino, electronics, robotics, hacking)
Nov 29, 2016
Profile Iconswapnil and Yasser joined GarageLab (arduino, electronics, robotics, hacking)
Nov 28, 2016
udit is now a member of GarageLab (arduino, electronics, robotics, hacking)
Nov 25, 2016
Aqeel munir is now a member of GarageLab (arduino, electronics, robotics, hacking)
Nov 23, 2016

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service