Skip to content
회로도전자부품
2013.11.22 16:26

아두이노 + 프로세싱2 오실로스코프 만들기

조회 수 15223 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

아두이노 + 프로세싱2 오실로스코프 만들기

 

오실로스코프 만들기 참고 사이트 : http://pepsiman.tistory.com/80

 

일단 아두이노는 이전 포스팅의 전압계 프로그램을 넣어 놓습니다.

 

 

프로세싱 프로그램 다운로드 참고사이트 : https://processing.org/download/?processing

 

2.1 (27 October 2013)

 

 

processing에 다음 코드를 붙여 넣게 합니다.
/*
 * Oscilloscope
 * Gives a visual rendering of analog pin 0 in realtime.
 * 
 * This project is part of Accrochages
 * See http://accrochages.drone.ws
 * 
 * (c) 2008 Sofian Audry (info@sofianaudry.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */ 
import processing.serial.*;

Serial port;  // Create object from Serial class
int val;      // Data received from the serial port
int[] values;
String s;

void setup() 
{
  size(640, 480);
  // Open the port that the board is connected to and use the same speed (9600 bps)
  port = new Serial(this, "COM3", 9600);
  values = new int[width];
  smooth();
}

int getY(int val) {
  return (int)(val / 600.0f * height) - 1;
}

void draw()
{
  while (port.available() >= 1) {
    //if (port.readString() == 0xff) {
    //  val = (port.read() << 8) | (port.read());
    //}
    s = trim(port.readString());
    val =   int(s );
    println(val);
  }
  for (int i=0; i<width-1; i++)
    values[i] = values[i+1];
  values[width-1] = val;
  background(0);
  stroke(255);
  for (int x=1; x<width; x++) {
    line(width-x,   height-1-getY(values[x-1]), 
         width-1-x, height-1-getY(values[x]));
  }
}

 

 

 

 

 

 

 

 

 

로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
173 AVR 아두이노를 이용한 Motor 제어(TA8050P) 3 file 2012.08.02 8071
172 AVR 아두이노로 할 수 있는 아이디어 및 프로젝트, 기타 정보 모음 2 1 2012.08.30 13159
171 회로도전자부품 아두이노NANO 스위치로 릴레이 제어하기 2020.06.13 7213
170 AVR 아두이노(우노UNO)와 HC-06 블루투스 모듈 연결하기(성공) 2 5 file 2012.08.17 13875
169 AVR 아두이노(우노UNO)와 HC-06 블루투스 모듈 연결하기 3 file 2012.08.17 9362
168 AVR 아두이노 프로그램 설치하고 프로그래밍 해보기 file 2012.07.24 5418
167 AVR 아두이노 카페 2013.08.17 12556
166 회로도전자부품 아두이노 주파수 측정 file 2014.01.06 13114
165 AVR 아두이노 전압측정(오실레이터가 없을때 활용) file 2013.10.18 27385
164 AVR 아두이노 예제소스코드) 13번핀 1초마다 on/off 반복시키기 1 2 2012.07.24 6187
163 AVR 아두이노 예제) LED 속도 가속 또는 랜덤화 하기 + 시리얼 통신까지 20 2012.08.04 11292
162 AVR 아두이노 예제) LED 속도 가속 또는 랜덤화 하기 2012.07.24 4835
161 AVR 아두이노 업로드 통신 설정방법 file 2019.06.13 15745
160 회로도전자부품 아두이노 시간함수 BlinkWithoutDelay 함수 2019.06.26 6085
159 AVR 아두이노 스케치 프로그램 3 file 2012.08.04 7198
158 AVR 아두이노 스위치로 LED 제어하기 2019.06.23 8336
157 회로도전자부품 아두이노 스위치 제어 알람 릴레이 조정기 2020.05.10 6235
156 AVR 아두이노 Uno + Thermistor 온도센서 사용해보기 3 file 2012.08.05 13758
155 AVR 아두이노 Uno + Cds Cell 5파이 광(빛감지) 감지센서 사용해보기 1 1 file 2012.08.05 11908
154 AVR 아두이노 PIR 센서를 이용하여 경고음 발생시키기 2020.04.30 8560
Board Pagination Prev 1 ... 3 4 5 6 7 ... 13 Next
/ 13

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소