0% found this document useful (0 votes)
28 views5 pages

#Include #Include #Include Int Void

The document contains code for an Arduino program that blinks LEDs in different patterns on ports A and B. It defines the ports as outputs, then enters a infinite loop where it sets the ports to different values, pauses for periods of time, to light the LEDs in sequence or together to create patterns, before repeating the loop indefinitely. It is blinking LEDs in a traffic light-like pattern across 4 circuits using delays to control the timing.

Uploaded by

arik kristiawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

#Include #Include #Include Int Void

The document contains code for an Arduino program that blinks LEDs in different patterns on ports A and B. It defines the ports as outputs, then enters a infinite loop where it sets the ports to different values, pauses for periods of time, to light the LEDs in sequence or together to create patterns, before repeating the loop indefinitely. It is blinking LEDs in a traffic light-like pattern across 4 circuits using delays to control the timing.

Uploaded by

arik kristiawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <avr/io.

h>
#include <avr/delay.h>
#include <util/delay.h>

int main(void)
{
DDRA=0xFF;
DDRB=0xFF;

while(1)
{
PORTA=0x61; PORTB=0x02; // MERAH DAN HIJAU
_delay_ms(5000);
PORTA=0x51; PORTB=0x02; // KUNING DAN FLASH
_delay_ms(500);
PORTA=0x41; PORTB=0x02; //
_delay_ms(500);
PORTA=0x51; PORTB=0x02; //
_delay_ms(500);
PORTA=0x41; PORTB=0x02; //
_delay_ms(500);
PORTA=0x4C; PORTB=0x02; //
_delay_ms(5000);
PORTA=0x48; PORTB=0x02; //
_delay_ms(500);
PORTA=0x4A; PORTB=0x02; //
_delay_ms(500);
PORTA=0x48; PORTB=0x02; //
_delay_ms(500);
PORTA=0x4A; PORTB=0x02; //
_delay_ms(500);
PORTA=0x09; PORTB=0x03; //
_delay_ms(5000);
PORTA=0x09; PORTB=0x02; //
_delay_ms(500);
PORTA=0x89; PORTB=0x02; //
_delay_ms(500);
PORTA=0x09; PORTB=0x02; //
_delay_ms(500);
PORTA=0x89; PORTB=0x02; //
_delay_ms(500);
PORTA=0x49; PORTB=0x08; //
_delay_ms(500);
PORTA=0x41; PORTB=0x00; //
_delay_ms(500);
PORTA=0x49; PORTB=0x04; //
_delay_ms(500);
PORTA=0x49; PORTB=0x00; //
_delay_ms(500);
PORTA=0x49; PORTB=0x04; //
_delay_ms(500);

}
}
/*
* I_Putu_Ari_Kristiawan.c
*
* Created: 19/04/2018 21.03.58
* Author: WINDOWS 10
*/

#include <avr/io.h>
#include <avr/delay.h>
#include <util/delay.h>

int main(void)
{
DDRA=0xFF;
DDRB=0xFF;

while(1)
{
PORTA=0x32;
PORTB=0x40;
_delay_ms(2000);

PORTA=0x52;
PORTB=0x40;
_delay_ms(500);
PORTA=0x12;
_delay_ms(500);
PORTB=0x52;
_delay_ms(500);

PORTA=0x52;
PORTB=0x40;
_delay_ms(500);
PORTA=0x12;
_delay_ms(500);
PORTB=0x52;
_delay_ms(500);
PORTA=0x12;
_delay_ms(500);
PORTB=0x52;
_delay_ms(500);
PORTA=0x12;
_delay_ms(500);
PORTB=0x52;
_delay_ms(500);

PORTA=0x86;
PORTB=0x40;
_delay_ms(2000);
PORTA=0x8A;
PORTB=0x40;
_delay_ms(500);
PORTA=0x82;
_delay_ms(500);
PORTA=0x91;
PORTB=0x40;
_delay_ms(500);
PORTA=0x90;
_delay_ms(500);
PORTA=0x91;
_delay_ms(500);
PORTA=0x90;
_delay_ms(500);
PORTA=0x91;
_delay_ms(500);
PORTA=0x90;
_delay_ms(500);
PORTA=0x91;
_delay_ms(500);

PORTA=0x92;
PORTB=0x10;
_delay_ms(2000);

PORTA=0x92;
PORTB=0x20;
_delay_ms(500);
PORTB=0x00;
_delay_ms(500);

PORTA=0x8A;
PORTB=0x40;
_delay_ms(500);
PORTA=0x82;
_delay_ms(500);
PORTA=0x8A;
_delay_ms(500);
PORTA=0x82;
_delay_ms(500);
PORTA=0x8A;
_delay_ms(500);
PORTA=0x82;
_delay_ms(500);
PORTA=0x8A;
_delay_ms(500);

PORTA=0x90;
PORTB=0xC0;
_delay_ms(2000);

PORTA=0x91;
PORTB=0x40;
_delay_ms(500);
PORTA=0x90;
_delay_ms(500);

PORTA=0x92;
PORTB=0x10;
_delay_ms(2000);
PORTA=0x92;
PORTB=0x20;
_delay_ms(500);
PORTA=0x00;
_delay_ms(500);
PORTA=0x20;
_delay_ms(500);
PORTA=0x00;
_delay_ms(500);
PORTA=0x20;
_delay_ms(500);
PORTA=0x00;
_delay_ms(500);
PORTA=0x20;
_delay_ms(500);

}
}

/*
* GILANGPRAKSA.c
*
* Created: 20/04/2018 01.42.48
* Author: WINDOWS 10
*/

#include <avr/io.h>
#include <avr/delay.h>
#include <util/delay.h>

int MerahA = 1;
int KuningA = 1;
int HijauA = 2;
int MerahB = 4;
int KuningB = 2;
int HijauB = 8;
int MerahC = 16;
int KuningC = 4;
int HijauC = 32;
int MerahD = 64;
int KuningD = 8;
int HijauD = 128;
int a;

int main(void)
{
DDRA=0xFF;
DDRB=0xFF;
while(1)
{
PORTA = HijauA|MerahB|MerahC|MerahD;
_delay_ms(2000);
PORTA=MerahB|MerahC|MerahD;
_delay_ms(1);
for (a=0;a<=2;a++)

PORTB = KuningA;
_delay_ms(500);
PORTB =! KuningA;
_delay_ms(500);
}
_delay_ms(500);
PORTA = MerahA|HijauB|MerahC|MerahD;
_delay_ms(2000);
PORTA = MerahA|MerahC|MerahD;
_delay_ms(1);
for (a=0;a<=2;a++)
{
PORTB = KuningB;
delay_ms(500);
PORTB =! KuningB;
delay_ms(500);
}
PORTA = MerahB|HijauC|MerahD|MerahA;
_delay_ms(2000);
PORTA = MerahB|MerahD|MerahA;
_delay_ms(1);
for (a=0;a<=2;a++)
{
PORTB = KuningC;
_delay_ms(1);
PORTB =! KuningC;
_delay_ms(500);
}
PORTA = MerahC|HijauD|MerahB|MerahA;
_delay_ms(2000);
PORTA = MerahC|MerahB|MerahA;
_delay_ms(1);
for (a=0;a<=2;a++)
{
PORTB = KuningD;
_delay_ms(1);
PORTB =! KuningD;
_delay_ms(500);
}

You might also like