0% found this document useful (0 votes)
13 views2 pages

Beginner Arduino Coding Guide

The document contains Arduino code snippets for controlling LEDs and buttons. It includes examples of toggling an LED state, counting button presses to control multiple LEDs, and using a for loop to print messages. Additionally, it demonstrates how to work with an array of integers and print their values to the serial monitor.

Uploaded by

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

Beginner Arduino Coding Guide

The document contains Arduino code snippets for controlling LEDs and buttons. It includes examples of toggling an LED state, counting button presses to control multiple LEDs, and using a for loop to print messages. Additionally, it demonstrates how to work with an array of integers and print their values to the serial monitor.

Uploaded by

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

int led=3,led2=4, btn=5

bool estado=false
void setup{
pinMode(led,OUTPUT);
pinMode(btn,INPUT);
}
void loop{
if (digitalWrite(btn)==HIGH){
estado=!estado;
delay(300);
}
if(estado==true){
digitalWrite(led,HIGH);
delay(200);
}
if(estado==false){
digitalWrite(led,LOW);
delay(200);
}

VARIABLE CONTADOR

int led=3,led2=4,btn=4,cont=0;
void setup{
pinMode(led,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(btn,INPUT);
}
void loop{
if(digitalWrite(btn)==HIGH)}
cont++;
delay(300);
}
if(cont==0){
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
delay(200);
}
else if(cont==1){
digitalWrite(led,HIGH);
digitalWrite(led2,LOW);
delay(200);
}
else if(cont==2){
digitalWrite(led,HIGH);
digitalWrite(led2,HIGH);
delay(200);
}
else if(cont==3){
cont=0;
}
}

BUCLE FOOOOOOOOR
int led=3,led2=4,btn=5,cont=0;
void setup{
Serial.begin(9600);
pinMode(led,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(btn,INPUT);
}
void loop{
for(int i;i<10;i++){
Serial.println("nro de repeticion");
Serial.print(i);
delay(1000);
}

ARRAY
int num[5]{7,2,21,15,3};
void setup{
Serial.begin(9600);
}
for(int i=0;i<5;i++){
Serial.println(num[i]);
delay(1000);
}
}

You might also like