"Arduino boards contain a multichannel, 10-bit analog to digital converter."
So, what happens when we put a voltage across two pins of the arduino?
The bits of Morse Code
Magentic Domains as bits
"Arduino boards contain a multichannel, 10-bit analog to digital converter."
This device generates a reference signal (in a step-like fashion). When it equals the input, it registers the digital value.
Arduino board have a similar method known as Successive Approximation ADC
We're measuring bits.
The Duty Cycle
Instead of making a range of voltages, the digital output works by changing how often 5 V is sent to the output. This is called the duty cycle.
The Two Sides of the board
// set up the pins
// our digital PWN output is set to Digital Out 9
const int outPin = 9;
// we start with an output of 0 and declare this variable as an integer
int outputLevel=0;
void setup() {
//define the pin mode for the digital output
pinMode(outPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// make an oscillating value
// output = Sin(omega * t)
float omega = 2*3.1415;
outputLevel = 255*sq(sin(millis()*.001*omega));
// write the outputLevel variable to our digital output pin
analogWrite(outPin, outputLevel);
delay(1);
}
The Duty Cycle
Connecting an LED
LED: Light Emitting Diode
Warning: One leg is longer - that goes to the positive voltage
Use a resistor in series to make sure not too much current passes. (220 Ω is fine)
If current passes through a resistor, there will some energy dissipation.
\begin{equation} P = I V = I^2 R \end{equation}We will use the digital output to send a current to a resister, and then use our thermistor module to measure that change in temperature of the resistor.
To do:
Connecting an LED
/* LED BRIGHTNESS CONTROL */
// our potentiometer will go to Analog Input 1
const int PotInputPin = A1;
// our digital PWN output is set to Digital Out 9
const int outPin = 9;
// we start with an output of 0 and declare this variable as an integer
int outputLevel=0;
void setup() {
//define the pin mode for the digital output
pinMode(outPin, OUTPUT);
}
void loop() {
int potValue = analogRead(A1);
// use the map() function to scale the potentiometer input from 0-1023 to 0-255
outputLevel = map(potValue,0,1023,0,255);
// write the outputLevel variable to our digital output pin
analogWrite(outPin, outputLevel);
delay(1);
}