Diferencia entre revisiones de «Taller de Arduino»
Ir a la navegación
Ir a la búsqueda
Sin resumen de edición |
Sin resumen de edición |
||
| Línea 107: | Línea 107: | ||
digitalWrite(A5, LOW); delay(300); | digitalWrite(A5, LOW); delay(300); | ||
} | } | ||
} | |||
void loop() { | |||
} | |||
</syntaxhighlight> | |||
===Codigo 6=== | |||
<syntaxhighlight lang="c++" line copy> | |||
const int INPUT_PIN = 2; | |||
void interrupt_handler() { | |||
const int input_pin_val = digitalRead(INPUT_PIN); | |||
digitalWrite(LED_BUILTIN, input_pin_val); | |||
} | |||
void setup() { | |||
pinMode(INPUT_PIN, INPUT_PULLUP); | |||
pinMode(LED_BUILTIN, OUTPUT); | |||
const int interrupt_number = digitalPinToInterrupt(INPUT_PIN); | |||
attachInterrupt(interrupt_number, interrupt_handler, CHANGE); | |||
} | } | ||
Revisión del 12:15 31 jul 2026
Temas a tratar en el taller de Arduino:
- ¿Qué es Arduino?
- ¿De dónde viene el concepto del Arduino?
- ¿Cuál es el propósito del Arduino?
- ¿Cuál es la relación de Arduino con el PC, Raspberry Pi, y otros dispositivos similares?
- ¿Cuáles son las versiones de Arduino?
- ¿El Arduino es código abierto?
- ¿Qué podemos hacer con un Arduino? ¿Que no es posible?
- ¿Qué ventajas tiene construir sistemas con Arduino en lugar de circuitos analógicos u otros chips digitales?
- Vamos a jugar con algunos ejemplos.
- ¿Como podemos analizar un sistema que contiene un Arduino para corregir errores? ¿Cuáles son las herramientas y técnicas para ayudar?
- Vamos a construir un sistema nuevo usando un Arduino.
https://github.com/contrem/arduino-timer
Ejemplos
Código 2
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
mySerial.begin(300);
}
void loop() {
mySerial.print("h");
delay(1000);
}
Código 3
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
mySerial.begin(300);
pinMode(13, OUTPUT);
}
void loop() {
if (mySerial.available()) {
char c = mySerial.read();
if (c == 'h') {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
}
delay(50);
}
Código 4
#define USE_TIMER_1 true
#include "TimerInterrupt.h"
unsigned int outputPin1 = LED_BUILTIN;
#define TIMER1_INTERVAL_MS 300
void TimerHandler1(unsigned int outputPin = LED_BUILTIN) {
static bool toggle1 = false;
static bool started = false;
if (!started) {
started = true;
pinMode(outputPin, OUTPUT);
}
digitalWrite(outputPin, toggle1);
toggle1 = !toggle1;
}
void setup() {
ITimer1.init();
ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1, outputPin1);
}
void loop() {
}
Código 5
#include <SPI.h>
#include <SD.h>
File f;
void setup() {
pinMode(A5, OUTPUT);
SD.begin(4);
f = SD.open("data.txt", FILE_READ);
int x = f.parseInt();
for (int i = 0; i < x; i++) {
digitalWrite(A5, HIGH); delay(300);
digitalWrite(A5, LOW); delay(300);
}
}
void loop() {
}
Codigo 6
const int INPUT_PIN = 2;
void interrupt_handler() {
const int input_pin_val = digitalRead(INPUT_PIN);
digitalWrite(LED_BUILTIN, input_pin_val);
}
void setup() {
pinMode(INPUT_PIN, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
const int interrupt_number = digitalPinToInterrupt(INPUT_PIN);
attachInterrupt(interrupt_number, interrupt_handler, CHANGE);
}
void loop() {
}