KEMBAR78
Introduction to Arduino | PDF
Introduction to Arduino
KU1101 Pengantar Rekayasa dan Desain
What is Arduino?
 An open-source electronic microcontroller board
 Originally built for designer & artists – people with little technical expertise
 We can easily program to understand and interact with the environment
Board Comparison
Name Processor
Operating
/Input
Voltage
CPU
Speed
Analog
In/Out
Digital
IO/PWM
EEPROM
[kB]
SRAM
[kB]
Flash [kB] USB
UART
Mega
2560
ATmega25
60
5 V / 7-12
V
16 MHz 16/0 54/15 4 8 256 Regular
4
Uno
ATmega32
8P
5 V / 7-12
V
16 MHz 6/0 14/6 1 2 32 Regular
1
Nano
ATmega16
8
ATmega32
8P
5 V / 7-9
V
16 MHz 8/0 14/6
0.512
1
1
2
16
32
Mini
1
Exploring Arduino Board
Minimum Requirement for a Project
 Arduino Board
 USB Cable
 PC with Arduino IDE
 Power Adapter (7V to 12V)
Powering Up External Devices
 3.3V and 5V pins to power up external device
 GND to share common ground
 Vin and GND as Arduino power source
Analog Signal vs Digital Signal
 Nearly all physical processes are analog.
Start an Arduino Project
 Installing Arduino IDE
 Installing the Drivers
Arduino IDE
 Verify: check and compile
 Upload: compile and upload program to board
 Serial Monitor: communicate via serial connection with Arduino
Hello, World! (not really)
const unsigned int LED_PIN = 13;
const unsigned int PAUSE = 500;
void setup() {
// put your setup code here, to run once:
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_PIN, HIGH);
delay(PAUSE);
digitalWrite(LED_PIN, LOW);
delay(PAUSE);
}
Using Serial Ports
const unsigned int LED_PIN = 13;
const unsigned int BAUD_RATE = 9600;
void setup() {
// put your setup code here, to run once:
// Arduino Uno, 0=RX, 1=TX
pinMode(LED_PIN, OUTPUT);
Serial.begin(BAUD_RATE);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0) {
// read the first byte
int command = Serial.read();
if (command == '1') {
digitalWrite(LED_PIN, HIGH);
Serial.println("LED on");
} else if (command == '2') {
digitalWrite(LED_PIN, LOW);
Serial.println("LED off");
} else {
Serial.print("Unknown command: ");
Serial.println(command);
}
}
}
Common Components
Binary Dice
Push Button
Reference
 Malk Schmidt. Arduino, 2nd Edition. The Pragmatics Programmer. 2015
 Cornel Amariel. Arduino Development Cookbook. Packt Publishing. 2015
 Arduino Reference. https://www.arduino.cc/en/Reference

Introduction to Arduino

  • 1.
    Introduction to Arduino KU1101Pengantar Rekayasa dan Desain
  • 2.
    What is Arduino? An open-source electronic microcontroller board  Originally built for designer & artists – people with little technical expertise  We can easily program to understand and interact with the environment
  • 3.
    Board Comparison Name Processor Operating /Input Voltage CPU Speed Analog In/Out Digital IO/PWM EEPROM [kB] SRAM [kB] Flash[kB] USB UART Mega 2560 ATmega25 60 5 V / 7-12 V 16 MHz 16/0 54/15 4 8 256 Regular 4 Uno ATmega32 8P 5 V / 7-12 V 16 MHz 6/0 14/6 1 2 32 Regular 1 Nano ATmega16 8 ATmega32 8P 5 V / 7-9 V 16 MHz 8/0 14/6 0.512 1 1 2 16 32 Mini 1
  • 4.
  • 5.
    Minimum Requirement fora Project  Arduino Board  USB Cable  PC with Arduino IDE  Power Adapter (7V to 12V)
  • 6.
    Powering Up ExternalDevices  3.3V and 5V pins to power up external device  GND to share common ground  Vin and GND as Arduino power source
  • 7.
    Analog Signal vsDigital Signal  Nearly all physical processes are analog.
  • 8.
    Start an ArduinoProject  Installing Arduino IDE  Installing the Drivers
  • 9.
    Arduino IDE  Verify:check and compile  Upload: compile and upload program to board  Serial Monitor: communicate via serial connection with Arduino
  • 10.
    Hello, World! (notreally) const unsigned int LED_PIN = 13; const unsigned int PAUSE = 500; void setup() { // put your setup code here, to run once: pinMode(LED_PIN, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED_PIN, HIGH); delay(PAUSE); digitalWrite(LED_PIN, LOW); delay(PAUSE); }
  • 11.
    Using Serial Ports constunsigned int LED_PIN = 13; const unsigned int BAUD_RATE = 9600; void setup() { // put your setup code here, to run once: // Arduino Uno, 0=RX, 1=TX pinMode(LED_PIN, OUTPUT); Serial.begin(BAUD_RATE); } void loop() { // put your main code here, to run repeatedly: if (Serial.available() > 0) { // read the first byte int command = Serial.read(); if (command == '1') { digitalWrite(LED_PIN, HIGH); Serial.println("LED on"); } else if (command == '2') { digitalWrite(LED_PIN, LOW); Serial.println("LED off"); } else { Serial.print("Unknown command: "); Serial.println(command); } } }
  • 12.
  • 13.
  • 14.
  • 15.
    Reference  Malk Schmidt.Arduino, 2nd Edition. The Pragmatics Programmer. 2015  Cornel Amariel. Arduino Development Cookbook. Packt Publishing. 2015  Arduino Reference. https://www.arduino.cc/en/Reference