Folgende Warnungen sind aufgetreten:
Warning [2] Undefined variable $unreadreports - Line: 34 - File: global.php(961) : eval()'d code PHP 8.2.24 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/global.php(961) : eval()'d code 34 errorHandler->error_callback
/global.php 961 eval
/showthread.php 28 require_once
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 43 - File: showthread.php(1621) : eval()'d code PHP 8.2.24 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1621) : eval()'d code 43 errorHandler->error_callback
/showthread.php 1621 eval




Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
RTC DS 1302
#7
der python code wird fehlerhaft dargestellt (falsch eingerückt). so muss es sein:

Code:
# !/usr/bin/env python
# -----------------------------------------------------
#
# This is a program for DS1302 RTC Module.
# It provide precision timmer.
#
# This program depend on rpi_time.py.
#
# ds1302 Module Pi
# VCC ------------------ 5 V (Must be 5v)
# GND ------------------ GND
# SCL ---------------- Pin 16
# SDA ---------------- Pin 18
# RST ---------------- Pin 22
#
# -----------------------------------------------------
from datetime import datetime
import ds1302
import rpi_time
import time

rtc = rpi_time.DS1302()


def setup():
    print ''
    print ''
    print rtc.get_datetime()
    print ''
    print ''
    a = raw_input("Do you want to setup date and time?(y/n) ")
    if a == 'y' or a == 'Y':
        date = raw_input("Input date:(YYYY MM DD) ")
        time = raw_input("Input time:(HH MM SS) ")
        date = date.split()
        time = time.split()
        print ''
        print ''
        ds1302.set_date(int(date[0]), int(date[1]), int(date[2]))
        ds1302.set_time(int(time[0]), int(time[1]), int(time[2]))
        dt = rtc.get_datetime()
        print "You set the date and time to:", dt


def loop():
    while True:
        a = rtc.get_datetime()
        print a
        time.sleep(0.5)


def destory():
    GPIO.cleanup()  # Release resource


if __name__ == '__main__':  # Program start from here
    setup()
    try:
        loop()
    except KeyboardInterrupt:  # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
        destory()
Zitieren


Nachrichten in diesem Thema
RTC DS 1302 - von Tekkineo - 24.09.2016, 09:49
RE: RTC DS 1302 - von otterstedt - 25.09.2016, 09:36
RE: RTC DS 1302 - von Tekkineo - 27.09.2016, 14:33
RE: RTC DS 1302 - von Jack - 27.09.2016, 22:22
RE: RTC DS 1302 - von Tekkineo - 28.09.2016, 06:38
RE: RTC DS 1302 - von Tekkineo - 06.10.2016, 17:15
RE: RTC DS 1302 - von harryberlin - 06.10.2016, 20:33
RE: RTC DS 1302 - von Jack - 06.10.2016, 22:56
RE: RTC DS 1302 - von Tekkineo - 07.10.2016, 10:44
RE: RTC DS 1302 - von harryberlin - 07.10.2016, 11:25
RE: RTC DS 1302 - von Tekkineo - 07.10.2016, 17:28
RE: RTC DS 1302 - von harryberlin - 08.10.2016, 10:57
RE: RTC DS 1302 - von Tekkineo - 08.10.2016, 17:20
RE: RTC DS 1302 - von harryberlin - 09.10.2016, 09:12

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste
RasPiCarProjekt