Hola

Páginas: 3 (579 palabras) Publicado: 15 de mayo de 2012
CODIGO CONTADOR
//unsigned short (int) data[16]= (0x40,0xf9,0xA4,0XB0,0X99,0X92,0X82,0XF8,0X80
// 0X98,0X88,0X83,0XC6, 0XA1,0X84,0X8E);
unsigned short int inc;void main (){
adcon1=7;
trisa.f0=1;
trisd=0x00;
portd=0xff;
delay_ms(1000);
for (;;){
portd= inc;
delay_ms(400);
if(porta.f0==1) {
inc=inc+1 ;
if (inc>=10)
inc=0; }
if(porta.f0==0) {
inc--;
if (inc<=0) inc=10; } } }

SERVO

* Project name:
unsigned cnt;
unsigned i;
unsigned pos;
void interrupt() {
cnt++;// Increment value of cnt on every interrupt
TMR0L = 102;
INTCON = 0x20; // Set T0IE, clear T0IF
}
void main() {
ADCON1 = 0x0F; // Set AN pins to DigitalI/O
T0CON = 0xC4; // Set TMR0 in 8bit mode, assign prescaler to TMR0
TRISB = 0; // PORTB is output
trisc=255;
PORTB = 0x00; // Initialize PORTBTMR0L = 102; // Timer0 initial value
INTCON = 0xA0; // Enable TMRO interrupt
cnt = 0;
pos=40; // Initialize cnt
inicio: {
if (portc==254){
pos++;if (pos>=140){
pos=140; } }
if (portc==255){
pos--;
if (pos<=40){
pos=40; } }
portb=255; // Set
delay_us(604);
for(i=0;i<pos;i++) { // 40 -90º a140 +90º ; }
portb=0; // Reset }
goto inicio; }
ADC_TX_RX

ADC_TX
unsigned int valor,valor1;
void main() {
trisd=255;
portd=0;
trisb=0;
portb=0;
trisa.F0=1;trisa.F1=1;
ADCON1=0x84;
USART_Init(9600);
Delay_ms(100);
while(1){
valor=ADC_Read(0);
valor=valor/4;
USART_Write(valor);
Delay_ms(1000);valor1=ADC_Read(1);
valor1=valor1/4;
USART_Write(valor1);
delay_ms(1000);
if(portd==0){
USART_Write(80); }
if(portd==1){...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • hola hola hola hola
  • hola hola hola hola hola
  • hola hola hhola hola y hola
  • hola hola hola
  • Hola Hola Hola
  • Hola Hola Hola
  • hola hola hola
  • Hola hola

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS