-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnewmain.c
More file actions
41 lines (35 loc) · 975 Bytes
/
newmain.c
File metadata and controls
41 lines (35 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* File: newmain.c
* Author: Aldo Axel Alcántar Aguirre
*
* Created on 28 de marzo de 2013, 03:07 PM
*
* Este programa lee el valor desde un sensor analógico de temperatura
* MCP9700A y lo transmite a través de la UART del PIC16F877A.
*/
//Este es un comentario que solo sirve para ver diff.. Nada mas
#include <16f877a.h>
#device adc = 8
#fuses NOWDT,XT
#use delay (clock = 4000000)
#use rs232(uart1, baud=9600)//RS-232, definimos UART y velocidad.
#use fast_io(b)//Optimizamos E/S del PORTB
void main ()
{
int valor;
float temp;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_tris_b(0xFE); //Pin RB0 como salida, el resto como entrada.
for(;;){
set_adc_channel(0);
delay_us(20);
valor = read_adc();
temp = (valor*100);
putc(temp);
output_low(PIN_B0); //Apaga el LED.
delay_ms(500); //Espera 500ms.
output_high(PIN_B0); //Enciende el LED.
delay_ms(500);
}
}