2013年5月12日日曜日

電子工作ゼミ2013開講

電子工作ゼミ2013(改め:建築工作ゼミ2012)開講

開講日:全12回 隔週月曜日 19:00-20:30

05/13 Processing1
05/27 Processing2
06/10 Arduino1
06/24 Arduino2
07/08 Processing+Arduino1
07/22 Processing+Arduino2
*前期はプログラミングと電子工作の基礎演習。

*後期は応用的な実験/演習を予定しています。
09/09 
09/30
10/21
11/11
11/25
12/09

*毎回各自のノートパソコンを持参してください。
*また、各自の興味あるデバイスなどがあれば、随時個人的に対応します。


2012年11月15日木曜日

次回11/20 Arduino+Processing

次回11/20は最後の授業となります。
ひきつづきArduinoとProcessingを連携させた応用実験を行います。

各自利用したいセンサ、あるいは出力デバイスなど持参し、ひとつの入出力デバイスの仕組みを各自の設定において構築したいと思いますので、次回までに各自の入出力デバイスのサンプルを考えて来て下さい。
授業内では、さらに他の人との入出力デバイスとの連携やワイヤレス化など、発展させたいと思います。

必要なもの:
・各自の入出力デバイスの案
・各自の入出力デバイスに必要なセンサや出力装置
・Arduino(マイコンボード、ブレッドボード、その他部品など)
・Processing (Webカメラなど含む)

2012年11月1日木曜日

次回11/06 Webカメラ+Arduino

次回11/06は、前回に引き続きWebカメラの応用実験(Webカメラを使ってArduinoを操作する)を行いたいと思います。

必要なもの:
・各自のノートパソコン
・Processingのインストール
・Webカメラ(パソコン内蔵カメラでも可)
・Arduinoボード
・USBケーブル
・ブレッドボード
・ジャンパワイヤ(オス-オス)



以下、授業内で使用したサンプル
import processing.video.*;
import processing.serial.*;

Serial myPort;
Capture video;

int w=240;//320;
int h=180;//240;

int tolerance=20;

PFont font;
color targetColor=color(255,0,0);

boolean videoImage=true;
float x;
float y;
float fx;
float fy;

int sumX,sumY;
int pixelNum;
boolean detection=false;

void setup(){
  size(w, h);
  smooth();

  video = new Capture(this, w, h);
  font=createFont("Monaco",10);
  textFont(font);
  noStroke();
  myPort=new Serial(this,"/dev/tty.usbserial-A9005baQ",9600);
}

void draw() {
  if(video.available()){
    video.read();
    if(videoImage){
      image(video, 0, 0);
    }else{
      background(0);
    }

    detection=false;
    
    for(int i=0;i<w*h;i++){

      float difRed=abs(red(targetColor)-red(video.pixels[i]));
      float difGreen=abs(green(targetColor)-green(video.pixels[i]));
      float difBlue=abs(blue(targetColor)-blue(video.pixels[i]));
      if(difRed<tolerance && difGreen<tolerance && difBlue<tolerance){
        sumX+=(i%w);
        sumY+=(i/w);
        pixelNum++;
        detection=true;
      }
    }
    
    if(detection){
      x=sumX/pixelNum;
      y=sumY/pixelNum;
      sumX=0;
      sumY=0;
      pixelNum=0;
    }
  }
  
  fx+=(x-fx)*0.2;
  fy+=(y-fy)*0.2;
  myPort.write(int(fx));
  fill(255,0,0);
  ellipse(fx,fy,20,20);
  fill(targetColor);
  rect(0,0,10,10);
  text(tolerance,20,10);
  String s;
  if(detection){
    s="detect";
  }else{
    s="none";
  }
  text(s,40,10);
}
void mousePressed(){
  targetColor=video.pixels[mouseX+mouseY*w];
  //println(int(red(targetColor))+","+int(green(targetColor))+","+int(blue(targetColor)));
}
void keyPressed(){
  if(key=='c'){
    video.settings();
  }
  if(key=='v'){
    if(videoImage){
      videoImage=false;
    }else{
      videoImage=true;
    }
  }
  if(key==CODED){
    if(keyCode==LEFT){
      tolerance-=1;
    }
    if(keyCode==RIGHT){
      tolerance+=1;
    }
  }
}


2012年10月16日火曜日

次回10/23 Processing+Webカメラ

次回10/23は、Webカメラを使った実験を行います。
また、Webカメラで得られたデータを使ってArduinoと連携させて出力します。

必要なもの:
・各自のノートパソコン
・Processingのインストール
・Webカメラ(パソコン内蔵カメラでも可)
・Arduinoボード
・USBケーブル
・ブレッドボード
・ジャンパワイヤ(オス-オス)

 内容:
Webカメラを使ったカラートラッキング

2012年10月4日木曜日

次回10/09 Arduino+Processing

次回10/09は、前回のシリアル通信(ArduinoとProcessingとの連携)をつかった応用演習をひきつづき行います。
各自が用意したセンサなど(使ってみたいセンサなど)あれば持参してください。

必要なもの:
・各自のノートパソコン
・Arduinoボード
・センサ類(各自持参) ・USBケーブル
・ブレッドボード
・ジャンパワイヤ(オス-オス)
・Processingのインストール

内容:
サーボ制御
・シリアル通信を使ったPrcessingからのサーボ制御

2012年9月20日木曜日

次回9/25 Arduino電子工作

次回9/25もArduino電子工作の演習を行います。
また、Processingとの連携のプログラムも予定していますので、Processingもインストールしておいてください。


必要なもの:
・各自のノートパソコン
・Arduinoボード
・USBケーブル
・ブレッドボード
・ジャンパワイヤ(オス-オス)
・Processingのインストール

内容:
シリアル通信(ArduinoとProcessingの連携)

2012年9月3日月曜日

後期授業開始:9/11 Arduino

後期授業は9/11から開始します。 前期にひきつづきArduino(電子工作)を行います。

必要なもの:
・各自のノートパソコン
・Arduinoボード
・USBケーブル
ブレッドボード
ジャンパワイヤ(オス-オス)

内容:
7セグLED表示
照度センサ
ピエゾスピーカ