Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
What is Arduino?
Arduino es un microcontrolador de una sola
tarjeta de tipo “open source”. Está diseñado
de tal forma que sean más accesibles los
proyectos de electrónica multidiciplinarios.
Entrada y salida
Salidas analógicas
// - Comentario simple
/* */ - Comentario múltiple
{ } – Usado para marcar el inicio y el final de un segmento de código
; - usado para finalizar una línea de código
Programming - Variables
Int (integer) – Almacena un número de dos bytes. (16 bits), no tiene punto
decimal. El valor debe estar entre -32,768 y 32,768.
boolean – Una variable que puede tomar los valores “true” o “false”. Es
útil, ya que sólo ocupa 1 bit de RAM.
!= (no igual)
< (menor que)
> (mayor que)
<= Menor o igual
>= mayor o igual
Primer Programa
/*
Blink
Turns on an LED on for one second, then
off for one second, repeatedly.
void setup() {
pinMode(rojo, OUTPUT);
pinMode( verde,OUTPUT);
}
void loop() {
digitalWrite(rojo, HIGH);
digitalWrite(verde, LOW);
delay(1000);
digitalWrite(rojo, LOW);
digitalWrite(verde, HIGH);
delay(1000);
}
int rojo=12,verde=11;
void setup() {
pinMode(rojo, OUTPUT);
pinMode( verde,OUTPUT);
}
void loop() {
digitalWrite(rojo, HIGH);
digitalWrite(verde, LOW);
delay(1000);
digitalWrite(rojo, LOW);
digitalWrite(verde, HIGH);
delay(1000);
}
Programming – Control Structures
These execute code based on CONDITIONS.
Here are just a few.
if(condition) { }
else if (condition) { }
else(condition) { }
This will execute the code between the curly braces if the
condition is true, and if not test the condition of the “else if”. If that
is false , the “else” code will execute.
Note: There are ways to use the board as analog. Those will be explained later.
Let’s Begin – Learning Goals
Learning Goals: The student will be able to:
1. Build a complete circuit using the Arduino microprocessor
2. Identify important electrical components in a circuit and explain their
use
3. Identify and apply specific elements in “C” code used to run a
program in conjunction with how a circuit is built
Scales of Measurement – Do you get it?
Lesson #1 – Blinking LED
What will you need? Arduino, breadboard, 4
wires, 10mm LED(large white), 560W resistor,
USB cable.
Schematic symbol
Resistors
Resistors restrict the amount of electrical
current that can flow through a circuit. The
color bands indicate the VALUE of the
resistor
Note: it is easy to grab the
WRONG one so be careful.
Also, it does not matter which
way the resistor is wired.
Schematic symbol
The schematic This is basically a SERIES circuit
where the resistor and LED are wired
one after another.
analogwrite(ledPin,new number)