/* * This program uses the arduino software which can be downloaded at www.arduino.cc * further documentation can also be found there. This program is designed to interface * with the processing program Data_visualization. It is only meant to output raw data * in order to be handled by Data_visualization. */ //Pin Declarations #define UVsensor 17 #define LED 24 //Variable Declarations int sensorValue; //value sensor reads from 0-1023 byte stat = 0; void setup() { pinMode(UVsensor, INPUT); //set UVsensor to input pin pinMode(LED, OUTPUT); //set LED to output pin digitalWrite(LED, LOW); //write LED high/low Serial.begin(9600);// open serial port, set the baud rate to 9600 bps } void loop() { sensorValue = analogRead(UVsensor); //line ensures that value is passed to variable before sent incomplete Serial.println(sensorValue); //outputs between 0-1023 (representative of 0-5V if(Serial.available() > 0){ stat = Serial.read(); if(stat == 1){ digitalWrite(LED, HIGH); } else if(stat == 0){ digitalWrite(LED, LOW); } else { Serial.print(stat); } } } /* void serialEvent() { stat = Serial.read(); if(stat == 1){ digitalWrite(LED, HIGH); } else if(stat == 0){ digitalWrite(LED, LOW); } } */