Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
50 views12 pages

ARDUINO

Uploaded by

sofihazel14
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)
50 views12 pages

ARDUINO

Uploaded by

sofihazel14
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/ 12

INSTITUTO TECNICO DE EXALUMNOS

SALESIANO

TEMA

ARDUINO

ASIGNATURA

1 er año electrónica sección a

PROFESOR

Carlos Vasquez

Hazel Sofia Vasquez Paredes.


PRACTICAS

GUIA 1

PRIMER EJERCICIO
// the setup function runs once when you press reset or power the
board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making
the voltage LOW
delay(1000); // wait for a second
}

// the setup function runs once when you press reset or power the
board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(500); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making
the voltage LOW
delay(500); // wait for a second
}
/ the setup function runs once when you press reset or power the
board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(200); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making
the voltage LOW
delay(200); // wait for a second
}

MODIFICACION DE CODIGO
int led= 3
int led 2 = 4

// the setup function runs once when you press reset or power the
board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED, OUTPUT);
pinMode(LED 2, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage
level)
delay(200); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the
voltage LOW
delay(200);

digitalWrite(LED 2, HIGH); // turn the LED on (HIGH is the


voltage level)
delay(200); // wait for a second
digitalWrite(LED 2, LOW); // turn the LED off by making the
voltage LOW
delay(200); // wait for a second
}

Semaforo
int button1=3;
int button2=4;
int led=13;
int x;
int y;

void setup()
{
pinMode(button1,INPUT);
pinMode(button2,INPUT);
pinMode(led,OUTPUT);
}

void loop()
{
x=digitalRead(button1);
if(x==1){

digitalWrite(led,1);
}

y=digitalRead(button2);

if(y==1)
{
digitalWrite(led,0);
}

Secuencias.
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT)
pinMode(4,OUTPUT)
pinMode(5,OUTPUT)
pinMode(6,OUTPUT)
pinMode(7,OUTPUT)
pinMode(8,OUTPUT)
pinMode(9,OUTPUT)
}

void loop() {
// put your main code here, to run repeatedly:
luces(1,0,0,0,0,0,0);
delay(500);
luces(0,1,0,0,0,0,0);
delay(500);
luces(0,0,1,0,0,0,0);
delay(500);
luces(0,0,0,1,0,0,0);
delay(500);
luces(0,0,0,0,1,0,0);
delay(500);
luces(0,0,0,0,0,1,0);
delay(500);
luces(0,0,0,0,0,0,1);
delay(500);
}

void luces(int a,int b,int c,int d,int e,int f,int g)


{
digitalWrite(3,a)
digitalWrite(4,b)
digitalWrite(5,c)
digitalWrite(6,d)
digitalWrite(7,e)
digitalWrite(8,f)
digitalWrite(9,g)

Secuencia display

Guia 2
Entradas digitales
int button=3;
int led=13;
int var;

void setup()
{
pinMode(button,INPUT);
pinMode(led, OUTPUT);
}

void loop()
{
var=digitalRead(button);
if(var==1)

{
digitalWrite(led,HIGH);
}
if(var==0)

{
digitalWrite(led,LOW);
}
}

2 pulsadores
int button1=3;
int button2=4;
int led=13;
int x;
int y;

void setup() {
pinMode(button1, INPUT);
pinMode(button2,INPUT);
pinMode(led,OUTPUT);
// put your setup code here, to run once:

void loop() {
x=digitalRead(button1);
if(x==1)
{
digitalWrite(led,1);
}
y=digitalRead(button2);
if(y==1)
{
digitalWrite(led,0);
}
return;
// put your main code here, to run repeatedly:

}
Lectura Analoguica

Lectura de potenciometro
int ledPin = 9;
int analogPin = 0;
int val = 0;
void setup()
{
pinMode(ledPin,OUTPUT);

void loop()

{
val= analogRead(analogPin);
Serial.print(val);
delay(1000);

Modificacion
#include <SoftwareSerial.h>
int ledPin = 9;
int analogPin = 0;
int val = 0;
float num;
void setup()
{
pinMode(ledPin,OUTPUT);
serial.begin(9600);
}
void loop()
{
val=analogRead(analogPin);
serial.print(val);
num=val*0.0049;
serial.print(num);
delay(1000);
}

2.Describa el funcionamiento de las entradas analógicas del Arduino


Los pines de entrada analógica de Arduino permiten leer valores analógicos que se
convertirán en valores dentro del rango de 0-1024, (2 elevado a la 10). Se trata de
una conversión analógica digital de 10 bits.
Lectura del potenciómetro y el uso de condiciones
para activar cargas

int ledPin = 9;
int analogPin = 0;
int val = 0;
void setup()
{
pinMode(ledPin,OUTPUT);
}
void loop(){
val = analogRead(analogPin);
Serial.print (val);
if (val>512)
{
digitalWrite(ledPin,HIGH);
}
if (val<=511)
{
digitalWrite(ledPin,LOW);
}
}

Modificación con 4 leds


int ledPin = 9;
int ledPin2 = 10;
int ledPin3 = 11;
int ledPin4 = 12;
int analogPin = 0;
int val = 0;

void setup()
{
pinMode(ledPin,OUTPUT);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
pinMode(ledPin4,OUTPUT);
}
void loop(){
val = analogRead(analogPin);
Serial.print (val);
if (val>512)
{
digitalWrite(ledPin,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);

}
if (val<=511)

digitalWrite(ledPin,HIGH);
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin3,HIGH);
digitalWrite(ledPin4,HIGH);
}

LDR
#include <SoftwareSerial.h>
int LightPin =3;
int ledPin =13;
int val = 0;
void setup(){
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop(){
val = analogRead(LightPin);
digitalWrite(ledPin,HIGH);
delay(val);
digitalWrite(ledPin, LOW);
delay(val);
Serial.print("Sensor de luz:");
Serial.println(val);
}

1. Describa el funcionamiento del programa


En el serial monitor se muestra con el nombre de sensor de luz
A través de números la cantidad de luz que recibe la LDR

2. Invierta la posición de la LDR y describa como afecta eso al


funcionamiento del programa
La cantidad de luz recibida bajo y no marca bien que tanta energía llega a
la LDR

ACTIVIDAD COMPLEMENTARIA

GUIA 4

SALIDAS PWM

Entendiendo el pwm

int digPin = 10;

void setup()

pinMode(digPin, OUTPUT);

void loop()

digitalWrite(digPin,HIGH);

delay(500);

digitalWrite(digPin,LOW)

delay(500)

Guia 4-2

int analogOutPin = 11;

byte outputValue = 0
void setup (){

void loop()

analogWrite(analogOutPin, outputValue);

delay(10);

outputValue++;

1. Describa el funcionamiento del programa

MODIFICAR EL PROGRAMA

#include <softwareSerial.h>

int analogOutPin = 11;

byte outputValue = 0;

void setup (){

Serial.begin(9600);

void loop()

analogWrite(analogOutPin, outputValue);

delay(10);

Serial.print(outputValue);

outputValue++;

You might also like