Intro to Arduino Akiba FreakLabs, Tokyo Hackerspace
Traditional embedded • What makes embedded development difficult? – Build tools – Software internals – Non standard hardware
Arduino • Why Arduino – Cheap – Standardized hardware – Vast libraries – Easy to program devices – Very active community
Arduino IDE
Arduino Hardware • Standardized • Open source • Many variants
Arduino Pins
Lab 1 – Hello World • Serial.begin(speed) – initializes serial port at given speed • Serial.print(string) – prints string • Serial.println(string) – prints string + trailing newline
Lab 2 – Blink • pinMode(pin, dir) – pin = pin number – dir = INPUT or OUTPUT • digitalWrite(pin, val) – pin = pin number – val = LOW or HIGH or 0 or 1 • analogWrite(pin, val) – pin = pin number – val = 0 to 255 – uses PWM – only for certain pins
Lab 3 - Fade • delay(time) – blocking delay in msec – time = msec
Lab 4 – Servo Motor • Hardware connection – Red = 5V – Black = GND – White = control -> goes to pin 9
Lab 4 – Servo Motor • Servo myservo – Creates servo object – Object has actions that can be accessed • myservo.attach – specifies which pin servo is on • myservo.write(pos) – value btw 0 and 180 specifies servo position
Lab 5 – Temperature Sensor • Hardware connections – Vin = 5V – GND = GND – Vout to Analog 0 • img/code from adafruit
Lab 5 – Temperature Sensor • analogRead(pin) – returns analog value btw 0 & 1023 – if using 5V supply as ref, full scale (1023) corresponds to 5V – voltage conversion (val / 1023) * 5V
Recommend
More recommend