tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/ds1307/sram/main.go (about) 1 package main 2 3 import ( 4 "machine" 5 6 "tinygo.org/x/drivers/ds1307" 7 ) 8 9 func main() { 10 machine.I2C0.Configure(machine.I2CConfig{}) 11 rtc := ds1307.New(machine.I2C0) 12 read := make([]byte, 5) 13 for { 14 rtc.Seek(0, 0) 15 _, err := rtc.Write([]byte{1, 2, 3, 4, 5}) 16 if err != nil { 17 println("Error while writing data:", err) 18 break 19 } 20 rtc.Seek(0, 0) 21 _, err = rtc.Read(read) 22 if err != nil { 23 println("Error while reading data:", err) 24 break 25 } 26 for data := range read { 27 println(data, " ") 28 } 29 30 } 31 32 }