Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Arduino 6 - Voltage Meter / Voltage Blink Due: Jun 20, 2018 at 11:59 PM 1. Volta

ID: 1300309 • Letter: A

Question

Arduino 6 - Voltage Meter / Voltage Blink Due: Jun 20, 2018 at 11:59 PM 1. Voltage Meter (analog read) 1. Create a voltage meter using the analogRead function 1. Read the voltage of a standard AA, AAA, C, or D battery 2. Display the current voltage value to the screen 3. Supplies: Standard battery 1. CAUTION!! DO NOT ATTEMPT TO TAKE THE VOLTAGE OFA BATTERY THAT IS OVER 5V, or in other words, DO NOT ATTEMPT TO TAKE THE VOLTAGE DIRECTLY OF A 9V BATTERY! 4. Extra Credit - Remembering that you NEVER want to hit the Arduino with more than 5V, think how you could measure the voltage of a battery (or battery pack) above 5V 1. Measure (and display) the voltage

Explanation / Answer

Here I posting the program for battery voltage less than or equal to 5v and Led blink respective to that voltage level. simply copy the program into the Arduino and connect the pins mentioned in the program.

#define Led 8//led pin number is 8

void setup()

{

Serial.begin(9600);

pinMode(Led,OUTPUT);

digitalWrite(Led,LOW);

}

void loop()

{

int sensorvalue = analogRead(A0);//input battery voltage applied across the analogA0 pin

if(sensorvalue<=266)//sensor value in bits for 1v the number of bits is 1023/5 equal to 204.6 and take approximately for other volatge values

{

float voltage = sensorvalue*(5.0/1023);

Serial.println(voltage);

digitalWrite(Led,LOW);

}

else if(sensorvalue>266&&sensorvalue<=512)

{

float voltage = sensorvalue*(5.0/1023);

Serial.println(voltage);

digitalWrite(Led,HIGH);

delay(250);

digitalWrite(Led,LOW);

delay(250);

}

else if(sensorvalue>512&&sensorvalue<=818)

{

float voltage = sensorvalue*(5.0/1023);

Serial.println(voltage);

digitalWrite(Led,HIGH);

delay(1000);

digitalWrite(Led,LOW);

delay(1000);

}

else if(sensorvalue>818&&sensorvalue<=1023)

{

float voltage = sensorvalue*(5.0/1023);

Serial.println(voltage);

digitalWrite(Led,HIGH);

}  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote