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.

how to convert into digital 8 analog input with microchip 16F877+8 led help please

Status
Not open for further replies.

maryanna

Newbie level 3
Newbie level 3
Joined
May 11, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
15
hello friends actually i'm facing a big problem with my project,i must find a program that convert 8 analog input into digital;i'm using micrichip 16F877+8 potentiometre+8led+max232+serial
this the code
Code:
 #include <16F877.h>
#device ADC=10 //N=10 pour le CAN interne
#use delay(clock=20000000) //Horloge à 20 MHz
#fuses HS,NOWDT,NOLVP
//#Défine ALL_ANALOG
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) //Configuration liaison série
void main()
{
int16 valeur; //Déclaration d'une variable valeur en entier 16 bits
setup_adc_ports(ALL_ANALOG); //Configuration des 8 voies du CAN en analogique
setup_adc(ADC_CLOCK_INTERNAL); //Utilisation de l'horloge interne
set_adc_channel(1);  //Utilisation de la voie 1 du micro-contrôleur (broche A1)
while(1)  //Boucle infinie
{
valeur=read_adc(); //Lecture de la broche A1, affectation à la variable valeur
      output_high();    //send a "1" to pin RB7, making RB7 "High" at 5v
            //this will turn on the LED hooked to RB7
      delay_ms(500);        //wait half a second, delays for 500ms 
      output_low();    
      delay_ms(1000);      //wait half a second, delays for 500ms
   }
}

=>no result please help

- - - Updated - - -

https://obrazki.elektroda.pl/3165609200_1399826539.jpg
 

Attachments

  • schemaisisfinal.BMP
    88.8 KB · Views: 71
Last edited by a moderator:

Zip and post your CCS C project files and Proteus file. Don't use MAX232 in Proteus. Connect COMPIM directly to PIC.
 
i mean that when i run the pic the led does not lights to show me that the conversion to digital is working
 

You have to set PORTB as output port first and then use below code to display on PORTB.


Code C - [expand]
1
2
3
4
5
6
7
8
for(i = 0; i < 7; i++) {
    
    set_adc_channel(i);
    valeur = read_adc();
    output_b(valeur);
        output_c(valeur >> 8);
    delay_ms(2000);
}

 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top