Difference between revisions of "Week 3 Lab"

From Robert-Depot
Jump to: navigation, search
(Analog Input)
(Analog Input)
Line 3: Line 3:
 
== Analog Input ==
 
== Analog Input ==
 
* File->Sketchbook->Analog->AnalogInput
 
* File->Sketchbook->Analog->AnalogInput
<code> 
 
  val = analogRead(potPin);    // read the value from the sensor
 
</code>
 
 
* Potentiometer
 
* Potentiometer
 
[[Image:Pot_in.png]]
 
[[Image:Pot_in.png]]
 
* Q: What will the voltage at A_IN be?  What are the upper and lower values?  
 
* Q: What will the voltage at A_IN be?  What are the upper and lower values?  
* Q: Looking at the Arduino help for the <code>analogRead()</code> function, what will the value <code>val</code> be for those highest and lowest voltages?
+
* The important part of this sketch is the line where the microprocessor reads the analog input:
 
+
<code> 
 +
val = analogRead(potPin);    // read the value from the sensor
 +
</code>
 +
* Q: Looking at the Arduino help for that function (<code>analogRead()</code>), what do you think the value <code>val</code> will be for those highest and lowest voltages in the previous question?
 +
* Q: How can you verify your idea?  
 +
=== other loads ===
 
* photoresistor from your 147A kit...  160k - ~10k (depending on your lighting conditions).
 
* photoresistor from your 147A kit...  160k - ~10k (depending on your lighting conditions).
 
* Q: With the same 10k resistor from the schematic above, what range of voltages (and corresponding data values) would you expect to see with this?
 
* Q: With the same 10k resistor from the schematic above, what range of voltages (and corresponding data values) would you expect to see with this?
* Q: How could we verify this?
 
 
 
* strain gauge
 
* strain gauge
 +
* ultrasonic rangefinder:
  
 
== Analog Output ==
 
== Analog Output ==

Revision as of 22:09, 12 April 2009

from Electronic Technologies for Art

Analog Input

  • File->Sketchbook->Analog->AnalogInput
  • Potentiometer

Pot in.png

  • Q: What will the voltage at A_IN be? What are the upper and lower values?
  • The important part of this sketch is the line where the microprocessor reads the analog input:

val = analogRead(potPin); // read the value from the sensor

  • Q: Looking at the Arduino help for that function (analogRead()), what do you think the value val will be for those highest and lowest voltages in the previous question?
  • Q: How can you verify your idea?

other loads

  • photoresistor from your 147A kit... 160k - ~10k (depending on your lighting conditions).
  • Q: With the same 10k resistor from the schematic above, what range of voltages (and corresponding data values) would you expect to see with this?
  • strain gauge
  • ultrasonic rangefinder:

Analog Output

LED Dimming

  • File->Sketchbook->Examples->Analog->Fading

   analogWrite(ledpin, value);           // sets the value (range from 0 to 255) 

PWM (pulse width modulation)

  • lights, fading

<youtube v="62gWVWCyw_w" loop="true"/>

Motor Speed Control

  • Basic motor control (DC motors) see week 5


Sound, Tone Generation

  • sounds, tone generation