¿¿Con interruptores??
				
			Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúPrivate Function Bits_d_tks(ByVal d As Long, ByVal n As Long) As Long
    If n And &H80000000 Then
        n = -n
        While n > 0
            d = desp_1pos_izq(d)
            n = n - 1
        Wend
    Else
        While n > 0
            d = desp_1pos_der(d)
            n = n - 1
        Wend
    End If
    Bits_d_tks = d
End Function
Private Function desp_1pos_izq(ByVal num As Long) As Long
Dim i As Long, b As Long
    b = 1
    For i = 0 To 29
        If num And b Then
            b = b * 2
            desp_1pos_izq = desp_1pos_izq Or b
        Else
            b = b * 2
        End If
    Next
    
    If num And &H40000000 Then
        desp_1pos_izq = desp_1pos_izq Or &H80000000
    End If
End Function
Private Function desp_1pos_der(ByVal num As Long) As Long
    If num <> &HFFFFFFFF And num <> 0 Then
        num = num \ 2
    End If
    desp_1pos_der = num
End Function
				
#include <16C62B.h>
#fuses XT,WDT
#use delay(clock=4000000,restart_wdt())
#use i2c(Master,Slow,SDA=PIN_C4,SCL=PIN_C3,RESTART_WDT)
 
int ByteR;
 
void main()
{
//Escribe el dato.
i2c_start();
i2c_write(0b10100110);
i2c_write(0x00);
i2c_write(0x10);
i2c_write(0x01);
i2c_stop();
delay_ms(5);
//Lee el dato.
i2c_start();
i2c_write(0b10100110);
i2c_write(0x00);
i2c_write(0x10);
i2c_start();
i2c_write(0b10100111);
ByteR = i2c_read(0);
i2c_stop();
 
output_bit(PIN_B0,ByteR);
 
}i2c_start();
i2c_write(0b10100110);  //Direeciona la eeprom en modo escritura.
i2c_write(0x10);  //Byte alto de la dirección a acceder.
i2c_write(0x52);  //Byte bajo de la dirección a acceder.
i2c_start();  //Envía restart.
i2c_write(0b10100111);  //Direcciona la eeprom en modo lectura.
dato=i2c_read(0);  //Lee el dato y no envía ACK.
i2c_stop();