Sep 24
1. Discuss homework. Do show'n'tell with an example consisting of
- Arduino sending out square wave with main loop delay
- Capacitor and pot with time constant varying through square wave's period
- Oscilloscope (and perhaps speaker) output across pot or cap
- Should see 0-5V square wave transition to either DC (low freq limit) or AC (hi freq limit).
2. Explain / demo other components in the lab kit
3. Assign midterm projects
- Rough draft due next Monday, Oct 1
- Final draft & class presentation due in 2 weeks, Oct 1
- The basic idea is to construct a demo using lab kit parts and others that you can easily get (e.g. powered speakers) of the basic Arduino scenario:
- input from X (photocell, buttons, microphone, ...)
- software loops, sees output, sends output
- output to Y (LED, motor, buzzer, speaker, ...)
- Something like what we've been doing for the last few weeks. Either follow a recipe or invent your own.
- Scale the level of the project to your experience, eh?
- See the examples page for some ideas.
4. Looking ahead
- Prelim project proposals (similar idea but more elaborate, including getting more parts as needed) due Oct 8 ; final proposal (including parts) due Oct 22. (15th is Hendricks)
- Expect more demos of coding practice and sample circuits
Aside :
/*
* square.ino
*
* generate a sqaure wave of a given frequency.
*
* Jim Mahoney | Sep 2012 | MIT License
*/
int wavePin;
int waveLevel; // HIGH or LOW
float freqHz; // of square wave
int halfCycleDelayMicroseconds;
int flip(int x){ // if x is HIGH, return LOW, and vice versa.
if (x == HIGH){
return LOW;
}
else {
return HIGH;
}
}
void setup() {
wavePin = 13;
waveLevel = HIGH;
freqHz = 50.0;
halfCycleDelayMicroseconds = int(1e6 * 0.5 / freqHz);
pinMode(wavePin, OUTPUT);
}
void loop() {
digitalWrite(wavePin, waveLevel);
waveLevel = flip(waveLevel);
delayMicroseconds(halfCycleDelayMicroseconds);
}