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

Design Procedure 1. 2. 3· Define the Gas tank capacity Assume that has a capacit

ID: 2249074 • Letter: D

Question

Design Procedure 1. 2. 3· Define the Gas tank capacity Assume that has a capacity of 96 Gallons The limitation of the analog Gas metering system is the number of lights in the display Number of lights 8 4. Calculate the Resolution of display Display Resolution-96 Gallons/8 lights- 12 Gallons/light Number of Lights On The Number of lights ON in the LED display will represent the Gallons remaining in the tank 96>Gas>84 Number of Lights ON Calculation. To find out what is the number of lights that need to be on for a particular number of gallons we can apply the following equation: Number of LED's ON = Integer [(Gallons + 1 1 ) / 12 For example: IfGallons-85 then: Number of lights ON (85 + 1 1 ) / 12-9612-8 If Gallons -84, then: Number of lights ON = (84-11) / 12-95/12-7 If gallons-48 then Number of lights ON = (48-11) / 12-27/4-4 Implementation.

Explanation / Answer

int i=0;

char buf[2];

int led_on=0;

int led = 1;

int led1 = 2;

int led2 = 3;

int led3 = 4;

int led4 = 5;

int led5 = 6;

int led6 = 7;

int led7 = 8;

void setup()

{

Serial.begin(19200); // Connect a 1kohm series resistor and LED to each output pin of arduino

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

pinMode(led4, OUTPUT);

pinMode(led5, OUTPUT);

pinMode(led6, OUTPUT);

pinMode(led7, OUTPUT);

pinMode(led, OUTPUT);

digitalWrite(led, HIGH);

  

}

void loop()

{

if (Serial.available()>0){

  

buf[i]= Serial.read();

if (int(buf[i])==13 || int(buf[i])==11 )

{ //If carriage return or new line entered

int result=atoi(buf);

Serial.print("Enter Gas volume ");   

if(result>96){

Serial.println("Warning: Volume exceeds limit");

}

led_on = (int)((result+11)/12 );

digitalWrite(led1, led_on>1?HIGH:LOW);

digitalWrite(led2, led_on>2?HIGH:LOW);

digitalWrite(led3, led_on>3?HIGH:LOW);

digitalWrite(led4, led_on>4?HIGH:LOW);

digitalWrite(led5, led_on>5?HIGH:LOW);

digitalWrite(led6, led_on>6?HIGH:LOW);

digitalWrite(led7, led_on>7?HIGH:LOW);

for(int x=0;x<=2;x++){

buf[x]=' ';

}

i=0;

} //clear buffer for next input

i++;

}

}