TTL input - 3rd states possible?


Results 1 to 27 of 27

Threaded View

  1. #16
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Not tested hastily made after reading post

    Hi,
    This is just an idea using the MChip Tips n' Tricks. No timer, no comparator just an idea. Flotulopex please test it out. Others on the forum please comment if it is crap.

    Name:  SWITCH.jpg
Views: 1053
Size:  13.6 KB
    Code:
    READ_SWITCH:
    TRISA.0 = 0             ' MAKE THE PIN AN OUTPUT
    PORTA.0 = 0             ' MAKE IT LOW
    PAUSE 100               ' WAIT FOR THE CAPACITOR TO DISCHARGE 
    
    TRISA.0 = 1             ' MAKE THE PIN AN INPUT
    PAUSE 100               '
    
    IF PORTA.0 = 1 THEN SWITCH_HIGH   '
    
    LED1    = 0             ' DEFINATELY NOT HIGH
    TRISA.0 = 0             ' MAKE THE PIN AN OUTPUT
    PORTA.0 = 1             ' MAKE IT HIGH
    PAUSE 100               '
    
    TRISA.0 = 1             ' MAKE THE PIN AN INPUT
    PAUSE 100               '
    
    IF PORTA.0 = 0 THEN SWITCH_LOW   '
    LED0       = 0          ' DEFINATELY NOT LOW
    
    GOTO READ_SWITCH
    
    SWITCH_LOW:
    LED0 = 1
    GOTO READ_SWITCH
    
    SWITCH_HIGH:
    LED1 = 1
    GOTO READ_SWITCH
    P.S. - The code can be made shorter!!
    Last edited by sougata; - 29th March 2007 at 11:00.
    Regards

    Sougata

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 19:51
  2. RB0 + Internal Pullup + Interrupt
    By Freman in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th August 2009, 12:11
  3. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 21:31
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 02:50
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 23:19

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts