You are on page 1of 8

My Goals What is a microcontroller?

Provide basic overview of Arduino • MCU is a computer-on-a-chip.


microcontroller (MCU) board and software
• Emphasizing self-sufficiency.
Show how easy it is to make this MCU • Cost-effectiveness.
work... all for about $35. • Integrates input/output interfaces.
• Specialized computing in a small package!
Presentation by Dante Bertelli
10/17/2007

What is Arduino? Choose your flavor!


• Open-source electronics prototyping
platform.
• Flexible.
• Easy-to-use hardware and software. “Normal”

• It's intended for artists, designers, Mini


hobbyists, and lazy mechanical
engineers.
• Way MEGA easy to program compared
to other microcontroller packages. XBee shield

Bluetooth
Lily Pads!
Basic Terminology – ADC
How can it be used?
(Analog to digital converter)
• Log data (external flash card).
• Analog signal IN.
• Cheap interface to PC (via serial, wireless
• The Arduino has 10 bits of
and USB protocols). resolution when reading analog
signals.
• Control larger currents using H-Bridges
• 210 = 1024 Increments
(variable) and relays (on/off).
• Influence by also how fast you
• Serve as a cheap replacement for a DAQ. sample.

Basic Terminology – PWM


Reference
(Pulse width modulation)
• http://www.arduino.cc/en/Reference/HomePage
• Analog signal OUT.

• The Arduino has 8 bit of resolution


when outputting a signal using
PWM.

• 0 to 5 Volts.

• 28 = 255 Increments

•Average of on/off (digital signals to


make an average voltage).

•Duty cycle in 100% of 5 Volts 1 1


5 255 pwm
volts
Data Types and Constants If
• Data Types • Constants • if (someVariable > 50) { • Operators:
Variables can have various types, Constants are particular values // do something here
which are described below. with specific meanings. • x == y (x is equal to y)
}
boolean HIGH | LOW • x != y (x is not equal to y)
char INPUT | OUTPUT
byte Integer Constants • if (x > 120) { • x < y (x is less than y)
int digitalWrite(LEDpin, HIGH); • x > y (x is greater than y)
unsigned int // Digital Out
long
• x <= y (x is less than or
}
unsigned long equal to y)
float • x >= y (x is greater than
double or equal to y)
string
array

For (counted loops) While (conditional loop)


• for (initialization; condition; increment) { • while(expression){
//statement(s); // statement(s) }
}

• for (int i=0; i <= 255; i++){ • var = 0;


analogWrite(PWMpin, i); //Analog Out while(var < 200){
delay(10); // do something repetitive 200 times
} var++;
}
Functions (return) Internal Functions
Because the digital pins works in
• A function to compare a sensor input to a • Digital I/O both directions!
threshold – pinMode(pin, mode) - SETUP
• int checkSensor(){ – digitalWrite(pin, value) - Digital OUT
if (analogRead(0) > 400) { – int digitalRead(pin) – Digital IN
return 1;
} else { • Analog I/O
return 0; } – int analogRead(pin) – Analog IN
} – analogWrite(pin, value) – Analog OUT (PWM)

Also look at using void… HARDWARE EXAMPLES

digitalWrite digitalRead
int ledPin = 13; // LED connected to digital pin 13
int ledPin = 13; // LED connected to digital pin 13 int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup()
{ void setup()
pinMode(ledPin, OUTPUT); // sets the digital pin as output {
} pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
void loop() }
{
digitalWrite(ledPin, HIGH); // sets the LED on void loop()
delay(1000); // waits for a second {
digitalWrite(ledPin, LOW); // sets the LED off val = digitalRead(inPin); // read the input pin
delay(1000); // waits for a second digitalWrite(ledPin, val); // sets the LED to the button's value
} }
analogRead analogWrite
int ledPin = 13; // LED connected to digital pin 13 int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
int analogPin = 3; // potentiometer connected to analog pin 3
int threshold = 512; // threshold int val = 0; // variable to store the read value

void setup() void setup()


{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output {
} pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin void loop()
if (val >= threshold) { {
digitalWrite(ledPin, HIGH); // sets the LED on val = analogRead(analogPin); // read the input pin
} else {
digitalWrite(ledPin, LOW); // sets the LED off analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023,
} analogWrite values from 0 to 255
} }

Location, Location, Location! Serial Communication


- 6 Analog In
- Digital I/O and Analog Out
• One bit at a time.
depends on configuration
• Can be archived over USB/Wireless

USB
XBEE
Serial Communication Serial Communication
int incomingByte = 0; // for incoming serial data
• Serial.begin(speed)
void setup() {
• Serial.available() }
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

• Serial.print(data) void loop() {

• Serial.println(data) // send data only when you receive data:


if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:


Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}

Serial Software How to install


• Hyperterminal • Download IDE
• LabView • Install USB serial drivers
• Matlab • Play!
• Visual Basic
• REALBasic
• C/C++
• What ever other respectable programming
language.
Interactive Real-Time Auditory Interactive Real-Time Auditory
Feedback System Feedback System
Wireless module

Medical Background - Transtibial Amputates Speaker

• Increased pressure put on intact limb Speaker


Microcontroller

• Higher prevalence of osteoarthritis in intact limbs knee


Pressure Atmel
Atmega8 Wireless
Sensor
Module
Application – Gait Asymmetry
• Evaluate asymmetry in gait
Computer
With LabView
• Interactively assists in correction of gait asymmetry Application

• Remote individual adjustment of trigger level by


Pressure sensors (FSR)
physical therapist

Interactive Real-Time Auditory Interactive Real-Time Auditory


Feedback System Feedback System
LabView Interface
Gate Data Acquisition System Gate Data Acquisition System

• Custom insole with 12 FSRs and 3 axis accelerometers each. Microcontroller


• (2 insoles) x (16 sensors / insole) x (100 hz / sensor) x
(10-bit ADC read / hz) = 32,000 bits/s. Wireless module
Custom
• 6-bytes x 8-bits/byte x 16-sensors x 100hz = 76800 bits/s. Insole program

• Multiplexer controller.
• Outputs data to SD card or PC via wireless connection.

Lets Browse Together!

http://www.arduino.cc/
http://www.sparkfun.com

You might also like