27 lines
654 B
C++
27 lines
654 B
C++
/* Name: Garrett Haldrup
|
|
<interfacingLightSensorVolt.ino>
|
|
Problem: Measure the output of a photo sensor and output the pin value and voltage value
|
|
Certification of Authenticity:
|
|
I certify that this assignment is entirely my own work.
|
|
*/
|
|
int lightSensorPin = A0;
|
|
|
|
int pinValue;
|
|
float pinValueVolt;
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
pinValue = analogRead(lightSensorPin);
|
|
pinValueVolt = (5.0 / 1023) * pinValue;
|
|
|
|
Serial.print("Pin Value: ");
|
|
Serial.print(pinValue);
|
|
Serial.print(" Voltage: ");
|
|
Serial.println(pinValueVolt, 2);
|
|
}
|