Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using a RTC in SF basic

MrDEB

Well-Known Member
I have a DS-1302 RTC module but how to use it?
I recall Jon Chandler made a vu meter clock but what he used for timing?
Am planning on a clock that has no hands, just LEDs but precision would be nice.
 
doing more research, it looks like the TM1637 is similar to the 74hc595
Popcorn did a project using the TM1637.
Wonder if the code was done in SF
 
Code:
// mrd 74HC595 TEST BOARD2
Device = 18F43K22
Clock = 8

// int osc and IO pin libraries
Include "intosc.bas"
#option DIGITALIO_INIT = true       // automatically call setalldigital
Include "setdigitalio.bas"
Include "SHIFT.BAS"

Dim LATCH As PORTB.4        // hc595 pin 12 LCHCLK
Dim DATA As PORTA.1         // hc595 pin 14 SDI
Dim CLK As PORTB.3          // hc595 pin 11 SFTCLK
Dim RST As PORTB.1          // hc595 pin 10 RSTn (no connection to pcb)
Dim SDO As PORTA.4          // hc595 pin 9 SDO QH' shift out

Dim Leds As Byte

// set pin modes
Shift.SetOutput(DATA)
Shift.SetClock(CLK)
Shift.SetInput(SDO)
high(RST)
low(LATCH)
 

 // if there was a connection...
low(RST)
delayus(100)
high(RST)


// cycle leds
leds = 0
while (true)
    if (leds = 0) then
        leds = 1
    endif
    Shift.Out(MSB_FIRST, DATA, 8)
    LATCH = 1
    LATCH = 0
    delayms(250)
    leds = leds << 1
end while
 
Last edited:
this project has changed its desired outcome kind of. https://www.electro-tech-online.com/threads/using-a-rtc-in-sf-basic.166376/post-1457998
FIRST the LED clock is going to use the schematic from post #173 as an example if I can do the mosfets correctly gezz
zzzz the present form of this is going to be a Christmas themed lighted ornament.
A snowflake, a Christmas tree (Jons idea) or redesign the Christmas star I made couple years ago that was designed wrong (2 LEDs in Parallel with 1 resistor)
The Christmashttps://www.electro-tech-online.com/threads/using-a-rtc-in-sf-basic.166376/post-1460076 tree idea
 
after layout parts I see the 74hc595's are a bit tooo wide'
contemplating using the smd mosfets but have several LEDs connected.
am looking at 96 leds The shift regesters don't fit to well between the leds of the snowflake
 

Attachments

  • PCB_PCB_SNOWFLAKE-11_2025-02-19.pdf
    951.5 KB · Views: 8
  • Screenshot (79).png
    Screenshot (79).png
    792.1 KB · Views: 9

Latest threads

New Articles From Microcontroller Tips

Back
Top