Complete the code to set the LED pin as output.
void setup() {
pinMode([1], OUTPUT);
}
void loop() {
// LED control code
}The built-in LED on most Arduino boards is connected to pin 13, so we set pin 13 as output.
Complete the code to turn the LED on.
void loop() {
digitalWrite(13, [1]);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}To turn the LED on, we set the pin to HIGH.
Fix the error in the code to correctly read battery voltage on analog pin A0.
int sensorValue = analogRead([1]); float voltage = sensorValue * (5.0 / 1023.0);
analogRead expects the analog pin number as an integer, so A0 is pin 0.
Fill both blanks to calculate battery voltage with a voltage divider.
float batteryVoltage = sensorValue * ([1] / 1023.0) * ([2] + 10.0) / 10.0;
The Arduino uses 5V reference, and the voltage divider resistors are 10k and 20k ohms, so we multiply by (20+10)/10.
Fill all three blanks to print battery voltage with 2 decimal places.
Serial.print("Battery Voltage: "); Serial.print([1], [2]); Serial.println([3]);
We print the variable batteryVoltage with 2 decimals, then print the unit " V" on a new line.
