/*Header
Writing a code to measure the voltage
within an LED-resistor ciruit
With measured voltage we can use Ohms law (V = IR)
To calcualte
voltage drop across any component
And current through component/circuit
*/
//global variables
//voltage reading variable
int voltreading; //currently no value
//in voltreading = 0; would be the equivalent to line 10
//using '=' assigns value to variable
//pin decleration
int ledpin = 8;
void setup() {
// put your setup code here, to run once:
//need to enable our pins
//LED pin --> power out --> actuator --> digital
pinMode(ledpin, OUTPUT);
//how to view values
//view values through serial moderator and serial plotter
Serial.begin(9600); //starts serial monitoring always set 9600
}
void loop() {
// put your main code here, to run repeatedly:
//run power through led
//outputs are digital
digitalWrite(ledpin, HIGH);
//HIGH = 1 ON
//LOW = 0 OFF
//measure voltage --> collect values
//sensor READ --> analog signal
voltreading = analogRead(A0);
//display values of interest
//Serial.print(voltreading);
//To improve readability ass text
//Serial.print(" | ");
Serial.println(voltreading);
//easiest way to read voltage ^^
//wokwi does not simulate current
delay(100);
//delays are in miliseconds
}