معرفی
- در این مقاله در مورد اتصال سنسور پالس با اپلیکیشن اندروید با آردوینو Mega2560 توضیح خواهم داد.
- می توان از آن برای ارائه اطلاعات صحیح در برنامه تلفن همراه استفاده کرد.
بخش هایی از لیست ها
- آردوینو مگا 2560
- سنسور پالس
- بلوتوث
- سیم ها را وصل کنید
- تخته های نان
سنسور پالس
- می توان از آن برای بررسی نبض بدن استفاده کرد.
- می تواند کاربر پسند باشد و توسط دانش آموزان، هنرمندان و توسعه دهندگان قابل استفاده باشد.
- می توان آن را پلاگین بازی نامید.
شکل 1: سنسور پالس
ارتباط
مرحله 1 اتصال از سنسور پالس به آردوینو مگا 2560
- آنها معمولاً می توانند سه پین داشته باشند.
- اولین پایه را می توان به پایه gnd آردوینو مگا 2560 متصل کرد.
- پایه دوم را می توان به vcc 5 ولت آردوینو مگا 2560 متصل کرد.
- سومی را می توان به وین پین آنالوگ Ao آردوینو مگا 2560 متصل کرد.
مرحله 2 اتصال از بلوتوث به آردوینو مگا 2560
- پین vcc را به 5 ولت آردوینو مگا 2560 وصل کنید.
- پایه gnd را به gnd آردوینو مگا 2560 وصل کنید.
- پین Tx را به RX وصل کنید.
- پین RX را به TX وصل کنید.
برنامه نويسي
- 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.
- // Regards Serial OutPut -- Set This Up to your needs
- static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse
- 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
- // analogReference(EXTERNAL);
- Genotronex.begin(9600);
- Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");
- pinMode(ledpin, OUTPUT);
- }
- // 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
- digitalWrite(blinkPin, HIGH); // Blink LED, we got a beat.
- 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
- } else
- {
- digitalWrite(blinkPin, LOW); // There is not beat, turn off pin 13 LED
- }
- ledFadeToBeat(); // Makes the LED Fade Effect Happen
- if (Genotronex.available())
- {
- BluetoothData = Genotronex.read();
- if (BluetoothData == '1')
- {
- // if number 1 pressed ....
- digitalWrite(ledpin, 1);
- Genotronex.println("LED On D12 ON ! ");
- }
- if (BluetoothData == '0')
- {
- // if number 0 pressed ....
- digitalWrite(ledpin, 0);
- Genotronex.println("LED On D12 Off ! ");
- }
- }
- delay(20); // take a break
- }
توضیح
- در این مقاله به وضوح در مورد سنسور پالس توضیح دادم
- این را می توان به وضوح در برنامه بلوتوث توضیح داد.
- هنگامی که نبض کم است، نمی تواند چشمک بزند
- هنگامی که نبض بالا است، می تواند چشمک بزند.