• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login

    running script?

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 259 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W Offline
      Wieee
      last edited by

      Hello

      I have mycontroller installed on a raspberry pi that got a 433mhz transceiver connected too it.
      What i wonder is if i can use mycontroller to schedule when too run the script, at the moment i run it with commands (ie python TransmitRF.py a_on b_on c_off)

      the script that I use looks like this (not mine taken from
      https://www.instructables.com/id/Super-Simple-Raspberry-Pi-433MHz-Home-Automation/)

      import time
      import sys
      import RPi.GPIO as GPIO
      
      a_on = '1111111111111010101011101'
      a_off = '1111111111111010101010111'
      b_on = '1111111111101110101011101'
      b_off = '1111111111101110101010111'
      c_on = '1111111111101011101011101'
      c_off = '1111111111101011101010111'
      d_on = '1111111111101010111011101'
      d_off = '1111111111101010111010111'
      short_delay = 0.00045
      long_delay = 0.00090
      extended_delay = 0.0096
      
      NUM_ATTEMPTS = 10
      TRANSMIT_PIN = 23
      
      def transmit_code(code):
          '''Transmit a chosen code string using the GPIO transmitter'''
          GPIO.setmode(GPIO.BCM)
          GPIO.setup(TRANSMIT_PIN, GPIO.OUT)
          for t in range(NUM_ATTEMPTS):
              for i in code:
                  if i == '1':
                      GPIO.output(TRANSMIT_PIN, 1)
                      time.sleep(short_delay)
                      GPIO.output(TRANSMIT_PIN, 0)
                      time.sleep(long_delay)
                  elif i == '0':
                      GPIO.output(TRANSMIT_PIN, 1)
                      time.sleep(long_delay)
                      GPIO.output(TRANSMIT_PIN, 0)
                      time.sleep(short_delay)
                  else:
                      continue
              GPIO.output(TRANSMIT_PIN, 0)
              time.sleep(extended_delay)
          GPIO.cleanup()
      
      if __name__ == '__main__':
          for argument in sys.argv[1:]:
              exec('transmit_code(' + str(argument) + ')')
      
      
      

      is it possible? and if it is, how?

      jkandasaJ 1 Reply Last reply Reply Quote 0
      • jkandasaJ Offline
        jkandasa @Wieee
        last edited by

        @Wieee It may not run as is. We have to check.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        1

        Online

        588

        Users

        529

        Topics

        3.4k

        Posts
        Copyright © 2015-2025 MyController.org | Contributors | Localization