---
title: Building the Bar Graph Display
slug: building-the-bar-graph-display
docTags: 
createdAt: 2023-11-28T18:37:18.378Z
---

## Lead in&#x20;

The bar graph display takes the input from AD0 and converts the value to be displayed on  8-BITs of a bar graph display.

## Code sample

Sample code for MikroC.

```c
unsigned int16 adcRead;
char ledBar[9]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};

void SetUp(){

TRISA = 0x01;
TRISD = 0x00;

}

void main(void){

  SetUp();

   while(1){
      
      adcRead=read_adc(0);
      
      //Wait for completion
      delay_ms(50);
      adcRead=(adcRead*9)/256;
      
      //Output the result to PORTD
      output_D(ledBar[adcRead]);
      delay_ms(50);
   }
}

```

## Lead Out

The code provided has been tested using a RADIX development board.
