Listing 1. Source Code for This Project #include #include // Data wire is plugged into digital port 10 on the Arduino #define ONE_WIRE_BUS 10 // Setup oneWire instance to communicate with OneWire temp device OneWire oneWire(ONE_WIRE_BUS); // Pass oneWire reference to Dallas Temperature DallasTemperature sensors(&oneWire); // Photocell input pin number int potPin = 0; // Declaration for photocell value int val = 0; // Arduino init functions void setup(void) { // Start serial port Serial.begin(9600); // Start up the library sensors.begin(); } // Celsius to Fahrenheit conversion function float c2f(float val){ float aux = (val * 9 / 5); return (aux + 32); } // Main Arduino program loop void loop(void) { // Read photocell for light value val = analogRead(potPin); // Send command to get temperature from Dallas device sensors.requestTemperatures(); // Convert returned C temp to F, print value Serial.print(c2f(sensors.getTempCByIndex(0))); // Print delimiter character in serial stream Serial.print("|"); // Print (w/line feed) light-level value Serial.println(val); delay(1000); }