Schritt 4: Programmieren der Arduino
Um genaue Proben zu erhalten, werden der Zeitgeber-Interrupts auf dem Arduino verwendet dieses Programmstruktur ein wenig anders als andere Arduino Programme aussehen könnte, an denen Sie mitgearbeitet haben. Diese Instructable hat viel mehr Details auf der Arduino-Timer, wenn Sie interessiert sind:
Der Code kann von GitHub (https://github.com/MoreCoffee12/SerialScope/tree/m...), die ZIP-Datei zu diesem Schritt befestigt, oder von unten eingegeben heruntergeladen werden.
// Firmware to capture 2-channels of data and send it out over BlueTooth. // This implementation is designed to provide data to the Windows Phone 8 // Application // // Software is distributed under the MIT License, see ArduinoFirmware_License.txt // for more details. // This library provides a frame structure // for the data. #include <minsegbus.h> MinSegBus mbus; // The SoftwareSerial library is used to provide // data to the Bluetooth module. #include <SoftwareSerial.h> SoftwareSerial BTSerial(10, 11); // RX | TX #define maxbuffer 0x0400 #define ADCChannels 0x0002 //storage variables boolean toggle0 = 0; // Define the ADC int analogPinCh1 = 0; int analogPinCh2 = 1; bool bOutput; // Buffers unsigned short iUnsignedShortArray[ADCChannels*2]; unsigned char cBuff[maxbuffer]; // MinSegBus vaiiables unsigned char iAddress; unsigned short iUnsignedShort; unsigned int iBytesReturned; unsigned int iErrorCount; unsigned int iIdx; void setup() { // Serial port setup Serial.begin(115200); BTSerial.begin(115200); // Definitions for the MinSegBus iAddress = 0x000; // Tattle tale pins, used to confirm timing pinMode(9, OUTPUT); // Get two samples before sending the frame bOutput = false; // Timer setup. Begin by disabling the interrupts // Reference: