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

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

조회 수 15226 추천 수 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
번호 분류 제목 날짜 조회 수
213 회로도전자부품 회로계산기(RLC, LC, dBm, Enter conversion, Volume resistivity, Reflection and refraction) 2013.08.31 18641
212 회로도전자부품 왜 이게 머리속에 잘 안들어오지? ㅎㅎㅎ 2013.12.04 18546
211 회로도전자부품 555 Timer Led 교차하여 깜빡이기 2013.10.15 18163
210 회로도전자부품 AC to DC Converter file 2013.09.09 18153
209 회로도전자부품 렉테나(rectanna: rectifying antenna, 정류 안테나) 동영상 2013.12.03 18021
208 회로도전자부품 DC to AC Converter 555 file 2013.09.05 17531
207 회로도전자부품 제너다이오드 & 브릿지다이오드 file 2013.09.05 17156
206 회로도전자부품 Rectenna 자료모음 file 2013.12.19 17076
205 회로도전자부품 안테나 길이 계산법 / 이론 2013.11.18 16919
204 AVR 열전 소자[ thermoelement , 熱電素子 ] file 2013.06.25 16766
203 회로도전자부품 레이저 다이오드 사용기 1 file 2013.08.24 16690
202 회로도전자부품 스텝업 & 스텝다운 원리 2013.11.20 16564
201 회로도전자부품 BOOST LIST file 2013.10.12 16322
200 회로도전자부품 충전보호회로 file 2013.11.22 16240
199 회로도전자부품 One transistor capacitance multiplier(발진기,바이브레이터) 2014.02.17 15961
198 AVR 아두이노 업로드 통신 설정방법 file 2019.06.13 15773
197 회로도전자부품 음계와 주파수 2013.11.08 15533
196 회로도전자부품 스털링엔진(온도차 발전기) file 2013.07.20 15527
195 회로도전자부품 아두이노와 1602 LCD 연결 file 2013.11.06 15477
» 회로도전자부품 아두이노 + 프로세싱2 오실로스코프 만들기 2013.11.22 15226
Board Pagination Prev 1 2 3 4 5 ... 13 Next
/ 13

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


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

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

설치 취소