2008 3.05: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
Tech Day 3.05
Tech Day 3.05


exercise
In-class Problem Set
 
Analog Sensor / Python Class
 
== Wiring a the analog sensor ==
 
We use a voltage divider, as in this example from the Making Things Talk text:
 
Image:Makingthings voltagedivider.png
 
 
== Write the Python program ==


a.
Create a "call and response" [[arduino]] application.
Create a "call and response" [[arduino]] application.
program the arduino to read one or more inputs (*at least one* analog), send the data only in response to reading a byte from it's serial port (the call)
program the arduino to read one or more inputs (*at least one* analog), send the data only in response to reading a byte from it's serial port (the call)
Line 9: Line 19:
Write a simple "proof of concept" receiver (in Python)
Write a simple "proof of concept" receiver (in Python)


b.
=== Relativizing Analog Input ===
Relativizing Analog Input
 


Use two variables, maxsensor and minsensor, to remember the highest and lowest sensor value your program as seen. Use these values to translate the sensor reading at any moment into a "scaler" that goes from 0 (when the sensor value is at the minimum) to 1 (sensor is at maximum).
Use two variables, maxsensor and minsensor, to remember the highest and lowest sensor value your program as seen. Use these values to translate the sensor reading at any moment into a "scaler" that goes from 0 (when the sensor value is at the minimum) to 1 (sensor is at maximum).

Revision as of 16:14, 15 May 2008

Tech Day 3.05

In-class Problem Set

Analog Sensor / Python Class

Wiring a the analog sensor

We use a voltage divider, as in this example from the Making Things Talk text:

Image:Makingthings voltagedivider.png


Write the Python program

Create a "call and response" arduino application. program the arduino to read one or more inputs (*at least one* analog), send the data only in response to reading a byte from it's serial port (the call)

Write a simple "proof of concept" receiver (in Python)

Relativizing Analog Input

Use two variables, maxsensor and minsensor, to remember the highest and lowest sensor value your program as seen. Use these values to translate the sensor reading at any moment into a "scaler" that goes from 0 (when the sensor value is at the minimum) to 1 (sensor is at maximum).

Use your scaler to control a visual PyGame property (size, color, position of a drawn shape, image).

c.

CREATE a Class called Sensor to encapsulate your min / max sensor reading code.