Sep 10 - arduino 101
aside: drawing circuits
- adafruit parts library - can download and incorporated many parts from our kit
- Very cool though not bulletproof.
Arduino Leonardo
The Leonardo features include :
- 20 input/output pins
- all 20 can do digital (i.e. 5 Volts or 0 Volt) input or output
- max output per pin is 40 mAmp (how much power is that?)
- for input, can turn on internal pull-up resistor 20-50 kOhm
- 7 of 'em can do a tricky kind of analog (i.e. time varying 0 to 5 Volt) output by "Pulse Width Modulation" (PWM - voltage is actually digital, but time average is analog)
- 12 of 'em can do analog input (0 to 5 Volt by default)
- a few other special pins / interfaces :
- serial (i.e. rs232), typically for characters to a computer
- SPI (one type of bus for connecting many inputs or outputs)
- TWI (another type of bus, using 2 pins to swap data with many things)
The leonardo also has a built-in LED (light emitting diode),
which is good for testing or indicating if its working -
see for example Blink program below.
And this version of the Arduino has a bunch of tricky USB stuff that lets it mimic a keyboard or a mouse as one way to send input into a laptop.
One reason the Arduino design has been more popular than other microcontrollers is that it doesn't need a separate "bootloader" to get the program into it. (Typically you can't just plug a microcontroller into your laptop without other stuff to make 'em work together.)
And it also has its own programming language (see below)
with tons of examples and an active support community.
There will be examples and explanations of this stuff as we go along.
other arduinos
We picked one version of the Arduino for this course,
but be aware that there are many variations. For example
installing the software
The software comes with many demo programs, including this Blink program.
Blink
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Its closely based on another programming language