mao arduino

of 69/69
阿爾杜伊諾 Arduino: Lv. 1 CęąĤó 2014.5.2 Mutienliao.com ¸huCğĝ·Œ3P MAO Sunday, May 4, 14

Post on 31-Aug-2014

511 views

Category:

Technology

2 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

  • Arduino: Lv. 1 2014.5.2 Mutienliao.com MAO Sunday, May 4, 14
  • Sunday, May 4, 14
  • Sunday, May 4, 14
  • Arduino Introduction Sunday, May 4, 14
  • What is Arduino? Sunday, May 4, 14
  • Arduino Hardware Arduino Software Open Source Physical Computing Platform & Group Sunday, May 4, 14
  • 14 Digital Pins 0-13 Digital Pins 0-1/Serial In/Out - TX/RX - Serial port Pin 0,1. 6 Analog Input Pins A0-A5 Analog Output * (Digital Pins 3,5,6,9,10,11) Reset - S1 Jumper USB DC (Duemilanove ) USB Vin, 5V, 3.3V (Diecimila ) Sunday, May 4, 14
  • Arduino........ Sunday, May 4, 14
  • Digital Out Digital In Analog In Analog Out Communication Sunday, May 4, 14
  • Digital Out Sunday, May 4, 14
  • Analog Out Sunday, May 4, 14
  • Digital In Sunday, May 4, 14
  • Analog In Sunday, May 4, 14
  • Communication Sunday, May 4, 14
  • Digital In Digital Out Analog In Analog Out Communication Emotion Experience Sunday, May 4, 14
  • Getting started w/ Arduino on your Computer Sunday, May 4, 14
  • 1 | Get an Arduino & USB cable Sunday, May 4, 14
  • | Prepare to test Arduino board - Arduino - LED Blink File > Examples > Basic > Blink Sunday, May 4, 14
  • | Set up your board : Tools > Board [ Mac OS X ] [ Mac OS X ] Arduino serial port: Tools > Serila Port Mac /dev/tty.usbserial- * [ Windows ] [ Windows ] Sunday, May 4, 14
  • | Upload the program Vertify Update to board* * Arduino NG Reset Update Arudino Reset Reset Update TX/RX LED 2~3 Pin13 pin ( ) File > Examples > Basic > Blink .... Sunday, May 4, 14
  • # | Troubleshooting Serial port Serial Port Serila port Jump Duemilanove/UNO Reset Reset Update Arudino USB Sunday, May 4, 14
  • (Voltage) (Current) Sunday, May 4, 14
  • LED LED ( ) LED LED ( ) Digital Outupt Circuit Sunday, May 4, 14
  • Digital Outupt Circuit Sunday, May 4, 14
  • Digital Outupt Circuit Sunday, May 4, 14
  • breadborad Sunday, May 4, 14
  • breadborad Sunday, May 4, 14
  • Digital Out Digital Out Sunday, May 4, 14
  • #1 | Blink Sunday, May 4, 14
  • Only 1 or 0 / High or LOW / ON or OFF HIGH LOW 1 0 Sunday, May 4, 14
  • int ledPin = 13; // LED connected to digital pin 3 void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPin, LOW); // sets the LED off delay(1000); // waits for a second } pinMode(pin, Mode) digitalWrite(pin, value) delay(ms) #1 File > Examples > Basic > Blink Sunday, May 4, 14
  • LED pin ? ( ) pin? pinMode(who, ?) ( ) digitalWrite(who,?) Sunday, May 4, 14
  • Sunday, May 4, 14
  • Digital Input Digital In Sunday, May 4, 14
  • #6 | Button Sunday, May 4, 14
  • #6 | Button #6 File > Examples > Digital > Button Sunday, May 4, 14
  • const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } } #6 File > Examples > Digital > Button Sunday, May 4, 14
  • Sunday, May 4, 14
  • #7 | StateChangDetection #7 File > Examples > Digital > StateChangDetection Sunday, May 4, 14
  • Analog Out Analog Out Sunday, May 4, 14
  • Analog Output PWM (Pulse Width Modulation) ( 0~5V) OutputVoltage = High_time(%) * Max_Voltage Arduino PWM pin 3,5,6,9,10,11 Sunday, May 4, 14
  • Arduino PWM pin 3,5,6,9,10,11 0~5V 0~255 analogWrite( pin, val ) Sunday, May 4, 14
  • #4 | Fade #4 File > Examples > Basic > Fade Sunday, May 4, 14
  • int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by void setup() { // declare pin 9 to be an output: pinMode(9, OUTPUT); } void loop() { // set the brightness of pin 9: analogWrite(9, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); } #4 File > Examples > Basic > Fade Sunday, May 4, 14
  • Servo Sunday, May 4, 14
  • DCDCPWM (1) 360PWM (2) PWM0~180 Sunday, May 4, 14
  • (..) V+. GND . pin (..) V+. GND . pin # File> Example> Servo> Sweep Sunday, May 4, 14
  • Sunday, May 4, 14
  • Analog Input Analog In Sunday, May 4, 14
  • Potentiometer Sunday, May 4, 14
  • Photocell get value get value get value Sunday, May 4, 14
  • Arduino A0~A5 0~5V 0~1023 analogRead( pin ) Sunday, May 4, 14
  • #10 | analog_control #10 http://code.mutienliao.tw/arduino/analog_control.pde Sunday, May 4, 14
  • int ledPin = 13; // LED connected to digital pin 13 int analogPin = 0; // photocell connected to analog pin 0 int val = 0; void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } void loop() { val = analogRead(analogPin); // read the value from the sensor if(val Analog > AnalogInOutSerial Sunday, May 4, 14
  • const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.print("t output = "); Serial.println(outputValue); // wait 10 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(10); } #11 File > Examples > Analog > AnalogInOutSerial Sunday, May 4, 14
  • Communication Communication Sunday, May 4, 14
  • Arduino USB RS-232 Serial HIGH / LOW Serial port Arduino C/C++,VB, MAX/MSP,VVVV, Processing FLASH( ) Sunday, May 4, 14
  • #12 | PC to Arduino #12 File > Example > Communication > PhysicalPixel Sunday, May 4, 14
  • RGB Sunday, May 4, 14
  • RGB LED Sunday, May 4, 14
  • RED 5V Blue Green LED Sunday, May 4, 14
  • Arduino pin 9 5V pin 10 pin 11 RED Blue Green #13 http://code.mutienliao.tw/arduino/common_anode_RGB.pde #13 http://code. mutienliao.tw/arduino/Serial_common_anode_RGB.ino Sunday, May 4, 14
  • #13 http://code.mutienliao.tw/arduino/common_anode_RGB.pde #13 http://code. mutienliao.tw/arduino/Serial_common_anode_RGB.ino Sunday, May 4, 14
  • RGB sensor Sunday, May 4, 14
  • VCC S1 S0 LED GND VCC S3 S2 OUT GND 5V pin 7 pin 6 GND pin 5 pin 4 pin 3 [Arduino] http://code.mutienliao.tw/arduino/LightSensing_Simple.ino Sunday, May 4, 14
  • [Arduino] http://code.mutienliao.tw/arduino/LightSensing_showcolor.ino [Processing] http://code.mutienliao.tw/processing/show_color.pde Sunday, May 4, 14