Advertisement
Guest User

Python to Arduino

a guest
May 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.04 KB | None | 0 0
  1. '''class Table:
  2.    def __init__ (self, l, w, h):
  3.        self.L = l
  4.        self.W = w
  5.        self.H = h
  6. class KitchenTable(Table):
  7.    def setPlaces(self,p):
  8.        self.places = p
  9. class DeskTable(Table):
  10.    def S(self):
  11.        return self.W * self.L
  12. class forSklad(DeskTable):
  13.    def O(self):
  14.        return self.S * self.H
  15. class computerTable(DeskTable):
  16.    def setComputerS(self,a):
  17.        self.computerS = a
  18.    def square (self):
  19.        return self.W * self.L - self.computerS
  20.  
  21. DenisStol = computerTable(1.5,0.7,1)
  22. DenisStol.setComputerS(0.09)
  23. AntonStol = DeskTable(1.5,0.7,1)
  24. print(AntonStol.S())
  25. print(DenisStol.S())'''
  26. things = 0
  27. chars = []
  28. pins = []
  29. tips = []
  30. funct = []
  31. work = []
  32. def Arduino():
  33.     print("сколько будет переменных?")
  34.     things = int(input())
  35.     for i in range(things):
  36.         print("введите имя ",i+1," переменной:")
  37.         chars.append(input())
  38.         print("введите пин ", i+1, " переменной:")
  39.         pins.append(input())
  40.         print("введите тип ", i+1, " переменной:")
  41.         tips.append(input())
  42.         print("введите функцию ", i+1, " переменной:")
  43.         funct.append(input())
  44.         print("как будет использоваться ", i+1, " переменная?")
  45.         work.append(input())
  46.     print("Вот программа:")
  47.     for i in range(things):
  48.         print("int ",chars[i]," = ",pins[i], ";")
  49.     print("void setup(){")
  50.     for i in range(things):
  51.         if(tips[i] == "o"):
  52.             print("   pinMode(",chars[i],"; OUTPUT);")
  53.         elif(tips[i] == "i"):
  54.             print("   pinMode(",chars[i],"; INPUT);")
  55.     print("}")
  56.     print("   void loop(){")
  57.     for i in range(things):
  58.         if (funct[i] == "l"):
  59.             print("   digitalWrite(",chars[i],", HIGH);")
  60.             print("   delay(1000);")
  61.             print("   digitalWrite(", chars[i], ", LOW);")
  62.             print("   delay(1000);")
  63.     print("}")
  64. Arduino()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement