Maxim-Dallas iButton 1-wire devices are widely used in security, timekeeping, temperature measuring and so on applications.
Gerard Sexton added iButton 1-wire support for DuinoMite so I decided to try it today.
We used to produce car immobilizers 20 years ago (when I type this I feel old🙂 ) so I found in our stock one iButton receptacle and Dallas DS1990 ROM button.
and wrote simple code to test it:
10 SETPIN 1,8 ‘LED output
as the receptacle have LED on it I decided to drive the LED with PIN(1) and to read the iButton with PIN(18) which is open collector
20 dim ar(10) ‘read iButton info
this defines the array where the read iButton info will be stored, later we can save this on file or to “learn” it and if later matched to open door lock, unlock car etc.
30 p = 18 ‘PIN(18) is used as iButton read as Open collector
40 PRINT “TOUCH iBUtton Please!”
now we are set and wait button to be pressed to the receptacle:
50 owreset p,presence ‘check for present
60 if presence = 1 then gosub 100 ‘if present read and display it
70 goto 50
if button is present the variable PRESENT =1 else 0
when the button is detected we write the info on the screen and blink the LED for 1/2 second:
100 ? “iButton detected:”;
110 owsearch p,1,ar(0): FOR I = 1 to 8: ? HEX$(AR(I));” “;:NEXT I: ?
120 PIN(1)=1: PAUSE 500: PIN(1) = 0 ‘blink the LED
now let’s see what happend when we run this code:
success, Well done Gerard!