/* Analog Value to Serial Using a Function * ------------ * by Jeff Gray * * Sends Analog value from pin 0 to serial out using a function */ //Function Prototype void serialSend(int data); //Pins int statusLED = 13; int analogPin = 0; //Variables int analogValue; void setup() { pinMode(statusLED, OUTPUT); // pin 13 status LED pinMode(analogPin, INPUT); // pin 0 for analog in beginSerial(9600); // initialize serial port } void loop(){ digitalWrite(statusLED, HIGH); analogValue = analogRead(analogPin); serialSend(analogValue/4); // send 1/4 of the analogValue to our function } void serialSend(int _data) { // this function formats our analog value for easy reading printInteger(_data); // print Integer serialWrite(10); // print carraige return and line feed serialWrite(13); }