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

PROGRAMAS EJEMPLOS 1 - ARDUINO - Ing Verástegui

The document contains multiple Arduino code snippets demonstrating different input and output configurations using bit and byte manipulation. It includes examples of reading from and writing to digital pins, as well as controlling output based on input signals. The code showcases various patterns and sequences for LED control using arrays and loops.

Uploaded by

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

PROGRAMAS EJEMPLOS 1 - ARDUINO - Ing Verástegui

The document contains multiple Arduino code snippets demonstrating different input and output configurations using bit and byte manipulation. It includes examples of reading from and writing to digital pins, as well as controlling output based on input signals. The code showcases various patterns and sequences for LED control using arrays and loops.

Uploaded by

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

BIT INPUT

void setup()
{
pinMode(13, OUTPUT);
pinMode(7, INPUT);
}

void loop()
{
digitalWrite(13, digitalRead(7));
delay(1);
}

BIT OUTPUT

void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}

BYTE INPUT
void setup()
{
PORTD=0x00;
DDRD=0xFF;
DDRB=0x00;
}

void loop()
{
PORTD = PINB;
}

BYTE OUTPUT
void setup()
{
DDRD=0xFF;
PORTD=0x00;
}

void loop()
{
PORTD = 15;
delay(500);
PORTD = 240;
delay(500);
}

-------------

int i;

void setup()
{
DDRD=0xFF;
PORTD=0x00;
}

void loop()
{
for(i=240; i<=255; i++)
{
PORTD = i;
delay(500);
}
}

---------------------

byte sec[]={1,2,4,8,16,32,64,128};
byte i;

void setup()
{
DDRD=0xFF;
PORTD=0x00;
}

void loop()
{
for(i=0; i<=7; i++)
{
PORTD = sec[i];
delay(500);
}
for(i=7; i>=0; i--)
{
PORTD = sec[i];
delay(500);
}
}

---------------------

byte sec[]={129,66,36,24};
int i;

void setup()
{
DDRD=0xFF;
PORTD=0x00;
}

void loop()
{
for(i=0; i<=3; i++)
{
PORTD = sec[i];
delay(500);
}
for(i=3; i>=0; i--)
{
PORTD = sec[i];
delay(500);
}
}

INPUT OUTPUT
byte sec[]={63,6,91,79,102,109,125,7,127,111};
int i=0;

void setup()
{
PORTD = sec[0];
DDRD=0xFF;
DDRB=0xFE;
}

void loop()
{
if (digitalRead(8))
{
i++;
if(i==10) i=0;
PORTD = sec[i];

while(digitalRead(8))
{
delay(10);
}
}

You might also like