/********* * Filename: PPM_Test.pde * Description: This program will gather 200 values of ppm pulse and send them to the serial port * Author: Marc Vieira Cardinal * Creation Date: August 14, 2008 * Revision Date: August 15, 2008 */ //PPM sensing parameters //Note: 1 millisecond = 1000 microseconds #define PIN_PPM 2 //The pin where the ppm receiver is connected #define PPM_SIGNALVALUE LOW //For normal ppm the channel value is low (set to high if reading an inverted trainer port) int ppmbuffer[200]; int x=0; void setup() { Serial.begin(9600); //Initialize the serial output pinMode(PIN_PPM, INPUT); //Set the ppm pin in input mode delay(2000); //Pause... } void loop() { if (x < 200) //Gather pulseIn values until the counter reach 200 ppmbuffer[x++] = pulseIn(PIN_PPM, PPM_SIGNALVALUE); else if (x == 200) //Display the content of the buffer { //Display some kind of separator Serial.println("**********START********"); //Loop and print the values for(int i=0; i < 200; i++) Serial.println(ppmbuffer[i]); x++; //This will prevent the program from gathering or displaying more values } }