BASIC4MCU | 질문게시판 | 아두이노 코드를 atmega128코드로 변환하고싶습니다!
페이지 정보
작성자 은리스탈 작성일2018-12-10 10:09 조회16,935회 댓글5건첨부파일
본문
/* Pulse Sensor Amped 1.5 by Joel Murphy and Yury Gitman http://www.pulsesensor.com
---------------------- Notes ---------------------- ----------------------
This code:
1) Blinks an LED to User's Live Heartbeat PIN 13
2) Fades an LED to User's Live HeartBeat PIN 5
3) Determines BPM
4) Prints All of the Above to Serial
Read Me:
https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino/blob/master/README.md
---------------------- ---------------------- ----------------------
*/
#define PROCESSING_VISUALIZER 1
#define SERIAL_PLOTTER 2
// Variables
int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0
int blinkPin = 13; // pin to blink led at each beat
int fadePin = 5; // pin to do fancy classy fading blink at each beat
int fadeRate = 0; // used to fade LED on with PWM on fadePin
// Volatile Variables, used in the interrupt service routine!
volatile int BPM; // int that holds raw Analog in 0. updated every 2mS
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".
volatile boolean QS = false; // becomes true when Arduoino finds a beat.
// SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS
// PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer
// https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
// SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter
// run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L
static int outputType = SERIAL_PLOTTER;
void setup(){
pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!
pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!
Serial.begin(115200); // we agree to talk fast!
interruptSetup(); // sets up to read Pulse Sensor signal every 2mS
// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
// analogReference(EXTERNAL);
}
// Where the Magic Happens
void loop(){
serialOutput() ;
if (QS == true){ // A Heartbeat Was Found
// BPM and IBI have been Determined
// Quantified Self "QS" true when arduino finds a heartbeat
fadeRate = 255; // Makes the LED Fade Effect Happen
// Set 'fadeRate' Variable to 255 to fade LED with pulse
serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
QS = false; // reset the Quantified Self flag for next time
}
ledFadeToBeat(); // Makes the LED Fade Effect Happen
delay(20); // take a break
}
void ledFadeToBeat(){
fadeRate -= 15; // set LED fade value
fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!
analogWrite(fadePin,fadeRate); // fade LED
}
아두이노 보드에 심박센서를 이용한 심박 측정기를 만드는 소스코드입니다. 제가 ATmega128 보드를 사용하고 싶은데 소스코드를 어떻게 바꿔야할지 모르겠습니다. 제가 가진 ATmega128 보드엔 D포트와 E포트 두가지만 사용이 가능합니다. LCD는 부착 되어있습니다. 위의 소스코드와 첨부한 소스코드를 한번 봐주시고 맞는지와 변환한 소스코드를 알려주시면 감사하겠습니다ㅠ
댓글 5
조회수 16,935master님의 댓글
master 작성일
https://www.google.co.kr/search?q=atmega128+%EC%8B%AC%EB%B0%95%EC%84%BC%EC%84%9C&oq=atmega128+%EC%8B%AC%EB%B0%95%EC%84%BC%EC%84%9C&aqs=chrome..69i57.5628j0j7&sourceid=chrome&ie=UTF-8
ATmega128로된 예제소스를 찾아서 공부하세요
은리스탈님의 댓글
은리스탈
다 찾아보고 해도 ATmega128로 된 오픈소스가 없어서 공부를 못하고 있습니다..ㅠ 도와주세요ㅠ
master님의 댓글
master 작성일
BPM값을 읽었다고 치고
AVR 모듈에 표시는 어떻게 할건가요?
나머지 부분은 할 수 있나요?
아나로그 값을 읽으려면 포트F를 사용해야 합니다.
은리스탈님의 댓글
은리스탈
ADC 포트가 하나 있는데 그 부분을 사용하면 가능할까요?
master님의 댓글
master
회로도 및 예제소스 등
가지고 있는 모든 자료를 첨부하셔야지 체크가 가능합니다.