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
5. Minimum Requirement for a Project
Arduino Board
USB Cable
PC with Arduino IDE
Power Adapter (7V to 12V)
6. 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
7. Analog Signal vs Digital Signal
Nearly all physical processes are analog.
8. Start an Arduino Project
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! (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);
}
11. 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);
}
}
}