7. RS232 – The Serial Port Asynchronous serial communications protocol No clock is sent - the receiver must provide the clock signal Data rate must be known by transmitter and receiver Arduino implements a ‘virtual’ serial port via USB http://arduino.cc/en/Reference/Serial
8. Voltage Levels Different devices may have different voltage levels Example: RS232 Voltage levels specified as +12/-12 volts in the standard Hooking these levels up to the micro will FRY it! Solution: Use a level converter
10. Virtual COM Ports Serial port via USB Applications think they are talking to a serial port, which is emulated by the drivers No need to have a physical serial port! Most new machines don’t have them anyway A LogicalChoice(tm) !
11. Example Project: Thermometer A temperature sensor is connected to an analog input on the Arduino Arduino periodically reports the temperature back to PC PC uses this data to plot graphs etc.
12. It’s an analog world… Digital – only has two values: on/off Analog – has many (infinite) values Computers don’t really do analog So they fake it, with quantization From Tod E. Kurt’s ‘Spooky Projects’ notes - http://todbot.com/blog/spookyarduino/
13. Thermometer: Arduino Code intsensorPin = 0; // the analog pin that the sensor is connected to void setup(){ Serial.begin(9600); } void loop(){ //getting the voltage reading from the temperature sensor int reading = analogRead(sensorPin); // converting that reading to voltage, for 3.3v arduino use 3.3 float voltage = reading * 5.0 / 1024; // print out the voltage Serial.print(voltage); Serial.println(" volts"); // now print out the temperature floattemperatureC = (voltage - 0.5) * 100; // converting from 10 mV per degree with 500 mV offset // to degrees ((voltage - 500mV) times 100) Serial.print(temperatureC); Serial.println(" degress C"); delay(1000); // wait a second } From Ladyada’s TMP36 Tutorial - http://www.ladyada.net/learn/sensors/tmp36.html
14. Thermometer: PC Side Read the incoming data every X seconds (cron) Collect and plot temperature graphs (rrdtool) Example: thermostat-graph http://www.anders.com/projects/thermostat-graph/ Not an Arduino project but easily hackable!