Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help me to built the circuit from coding

Status
Not open for further replies.

firdaus86

Newbie level 3
Joined
May 9, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
hye
anyone help me to built the circuit from my coding

see attachment for my coding
 

Code:
unsigned char ch;
unsigned int adc_rd;
unsigned char *text, *text1,*text2, *text3, *text4, *text5, *text6;
void Drive_Motor(unsigned int);
void ADC_CH0();
void ADC_CH1();
void ADC_CH2();
void Delay(unsigned int );

void main()
{
 unsigned int i;
 unsigned int a,b,c;
 
  INTCON = 0;                              // disable all interrupts
  TRISC = 0;                         // PORTC is output
  TRISD = 0;
  TRISA=0;
  TRISB=0;

  text = "SOLAR TRACKING";        // assign text to string
  text1 = "   SYSTEM  ";        // assign text to string
  text2= "    EAST";           //" ADC Channel 0";
  text3= "    MIDDLE";         //" ADC Channel 1";
  text4= "    WEST";           //" ADC Channel 2";
  text5= " NO LIGHT";
  text6= "PROPER LIGHT";
  Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTC,0,1,2);  // Initialize LCD on PORTB
  Lcd_Custom_Cmd(Lcd_CURSOR_OFF);           // Turn off cursor
  LCD_Custom_Out(1,1,text);                       // print string a on LCD, 1st row, 1st column
  LCD_Custom_Out(2,1,text1);                       // print string a on LCD, 2nd row, 1st column
  Delay_ms(1500);
  PORTB.F3 = 0;
  PORTB.F2 = 0;
  Lcd_Custom_Cmd(Lcd_Clear);
  ADCON1     = 0x82;          // configure VDD as Vref, and analog channels
  TRISA      = 0xFF;          // designate PORTA as input
  while (1)
  {
    Lcd_Custom_Cmd(Lcd_Clear);
    LCD_Custom_Out(1,1,text2);
    ADC_CH0();
    Delay(200);
    Lcd_Custom_Cmd(Lcd_Clear);
    LCD_Custom_Out(1,1,text3);
    ADC_CH1();
    Delay(200);
    Lcd_Custom_Cmd(Lcd_Clear);
    LCD_Custom_Out(1,1,text4);
    ADC_CH2();
    Delay(200);
  }
}


void Drive_Motor(unsigned data)
     {
          PORTB=data;
     }

void Delay(unsigned int t)
{
  unsigned int i, j;
	for(i=0; i<t; i++)
	for(j=0; j<1275; j++);
}

void ADC_CH0()
{
    unsigned int X,Y,Z1,Z2,Z3,LDR;
    adc_rd  = ADC_read(0);                // get ADC value from 2nd channel
    X=0;
		Y=0;
		Z1=0;
		Z2=0;
		Z3=0;                     // print string a on LCD, 2nd row, 1st column
    X=adc_rd;
    Y=X/10;
		Z1=X%10;
		Z2=Y%10;
		Z3=Y/10;
		if(X>150)
			{
       LCD_Custom_Out(2,1,text5);
       Delay_ms(500);
			}
			else
			{
      LCD_Custom_Out(2,1,text6);
      Delay_ms(500);
      PORTB.F3 = 1;
      PORTB.F2 = 0;
      Delay_ms(1000);
      PORTB.F3 = 0;
      PORTB.F2 = 0;
      Delay_ms(10000);
			}

}
void ADC_CH1()
{
    unsigned int X,Y,Z1,Z2,Z3,LDR;
    adc_rd  = ADC_read(1);                 // get ADC value from 2nd channel
    X=0;
		Y=0;
		Z1=0;
		Z2=0;
		Z3=0;                     // print string a on LCD, 2nd row, 1st column
    X=adc_rd;
    Y=X/10;
		Z1=X%10;
		Z2=Y%10;
		Z3=Y/10;
		if(X>150)
			{
       LCD_Custom_Out(2,1,text5);
       Delay_ms(500);
			}
			else
			{
       LCD_Custom_Out(2,1,text6);
       Delay_ms(500);
       PORTB.F3 = 0;
       PORTB.F2 = 1;
       Delay_ms(1000);
       PORTB.F3 = 0;
       PORTB.F2 = 0;
       Delay_ms(10000);
			}
}
void ADC_CH2()
{
     unsigned int X,Y,Z1,Z2,Z3,LDR;
    adc_rd  = ADC_read(2);                 // get ADC value from 2nd channel
    X=0;
		Y=0;
		Z1=0;
		Z2=0;
		Z3=0;                     // print string a on LCD, 2nd row, 1st column
    X=adc_rd;
    Y=X/10;
		Z1=X%10;
		Z2=Y%10;
		Z3=Y/10;
		if(X>150)
			{
       LCD_Custom_Out(2,1,text5);
       Delay_ms(500);
			}
			else
			{
       LCD_Custom_Out(2,1,text6);
       Delay_ms(500);
       PORTB.F3 = 0;
       PORTB.F2 = 1;
       Delay_ms(1000);
       PORTB.F3 = 0;
       PORTB.F2 = 0;
       Delay_ms(10000);
       PORTB.F3 = 1;
       PORTB.F2 = 0;
       Delay_ms(1000);
       PORTB.F3 = 0;
       PORTB.F2 = 0;
       
			}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top