Talk:Arduino

From XinCheJian
Jump to navigation Jump to search

here is the description for the course:

The Ultimate Arduino Workshop!

Date&Time: 2012, August 18th (Saturday) 1pm-6pm and August 19th (Sunday), 9Am to 5PM Fee: 800rmb/person - includes a 300rmb XinCheJian Arduino Starter Kit (Please pay at the workshop)

You will need a working Laptop with WiFi

People from the community will be running parts of this ultimate workshop.

Day 1 - Introduction to Arduino:

  • Introduction to programming using Arduino - 2 Hours
  • Introduction to Arduino - 2 Hours

Day 2 - Advanced Arduino Magic - 9am-12am

  • opening (20 minutes)
    • Alternative programming methods
    • Source Control
    • Designing your own circuit/shields
    • Manufacturing overview
  • Libraries (40 minutes)
    • Aiko Library
    • SPI/I2C
    • Processing (Visual)/MaxMSP (Audio)
    • Serial Communication between two Arduino
  • Interrupts (10 minutes)
  • Rref ( 5 minutes )
  • Dealing with Whacky Responses ( 10 minutes )
    • interrupts gone wild
  • Connecting your own devices (30 minutes)
    • Datasheets, understanding them and researching

Day 2 - Own project/Arduino Challenge - 1:30pm - 5pm / optional

  • Tour of XinCheJian
  • Hackerspace Etiquette
  • Start on your own project (3hours)

You have the opportunity to stay around in the afternoon and work on your own ideas at the Hackerspace. With people around to help you work through problems or point you in a direction, if you don't have an idea, no problem! just ask. Its a great way to get introduced to the community and get use to working in the Hackerspace.

NOTES: Please bring a laptop with the Arduino environment on it. It’s available at <a href="http://arduino.cc/en/Main/Software">http://arduino.cc/en/Main/Software</a>.

Serial Communication between two Arduino

Player 1


/* master code */

/* pins A4 and A5 */

#include <Wire.h> //need this for communication

void setup() {
  Serial.begin(9600);
  Wire.begin(2);               
  Wire.onRequest(requestEvent); 
}

void loop() {
  //nothing
}

void requestEvent() {
    Serial.println("sending data!");
    Wire.write(123); 
}

player 2



/* slave code */

/* pins A4 and A5 */

#include <Wire.h>

void setup() {
  // set up serial port
  Serial.begin(9600);
  Wire.begin();   
}

void loop() {
 
  /* we're going to poll for events */
   Serial.println("requesting data");
   Wire.requestFrom(2, 1); 
   while(Wire.available())  {
     int data = Wire.read();    
     Serial.print("data: ")'   
     Serial.println(data);
   }

  delay(10);

}

interupts


/* 
Interupts:  Pin 2 - interupt 0
            Pin 3 - interupt 1
            
http://arduino.cc/en/Reference/AttachInterrupt
mode defines when the interrupt should be triggered. Four contstants are predefined as valid values:

    LOW to trigger the interrupt whenever the pin is low,
    CHANGE to trigger the interrupt whenever the pin changes value
    RISING to trigger when the pin goes from low to high,
    FALLING for when the pin goes from high to low. 
            
*/

int interupted = 0;

void setup() {
  attachInterrupt(0, somefunction, CHANGE);
}

void loop() {
  if (interupted == 1) {
    interupted = 0;
    Serial.println("we got interupted!");
  } else {
    /* normal code */
  }
}

void somefunction() {
  interupted = 1;
}

maxmsp

http://v.youku.com/v_show/id_XMzI4MjAxNjI4.html http://v.youku.com/v_show/id_XMzE1Mjc4Nzk2.html