Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
raspi [2014/05/15 13:23] raivo.sellraspi [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 7: Line 7:
 <code c> <code c>
 5+9 5+9
- +print ("Tere Kevad")
-print (Tere Kevad) +
 56/5+99-14*9 56/5+99-14*9
- +print ("Tere Kevad")
-print (Tere Kevad) +
 3 > 7 3 > 7
- 
 for x in range (1,10): for x in range (1,10):
  print (x)  print (x)
Line 25: Line 20:
  
 <code c> <code c>
 +# -*- coding: utf-8 -*-
 kaal = float(input("Kui palju sa umbes kaalud? ")) kaal = float(input("Kui palju sa umbes kaalud? "))
 if kaal > 100: if kaal > 100:
Line 43: Line 38:
  
 import turtle import turtle
- 
 for i in range(5): for i in range(5):
     turtle.forward(50)     turtle.forward(50)
     turtle.right(144)     turtle.right(144)
- 
- 
 import turtle import turtle
- 
 turtle.pencolor("#3110BE") turtle.pencolor("#3110BE")
 for i in range(50): for i in range(50):
Line 66: Line 57:
 <code c> <code c>
  
-import tkinter as tk +import Tkinter as tk
 class Application(tk.Frame): class Application(tk.Frame):
     def __init__(self, master=None):     def __init__(self, master=None):
Line 73: Line 63:
         self.pack()         self.pack()
         self.createWidgets()         self.createWidgets()
- 
     def createWidgets(self):     def createWidgets(self):
         self.hi_there = tk.Button(self)         self.hi_there = tk.Button(self)
Line 79: Line 68:
         self.hi_there["command"] = self.say_hi         self.hi_there["command"] = self.say_hi
         self.hi_there.pack(side="top")         self.hi_there.pack(side="top")
- 
         self.QUIT = tk.Button(self, text="SULGE", fg="red",command=root.destroy)         self.QUIT = tk.Button(self, text="SULGE", fg="red",command=root.destroy)
         self.QUIT.pack(side="bottom")         self.QUIT.pack(side="bottom")
- 
     def say_hi(self):     def say_hi(self):
         print("Tere kevad!")         print("Tere kevad!")
- 
 root = tk.Tk() root = tk.Tk()
 app = Application(master=root) app = Application(master=root)
Line 96: Line 82:
 import RPi.GPIO as GPIO import RPi.GPIO as GPIO
 import time import time
- 
 ledPin = 11 ledPin = 11
- 
 GPIO.setmode(GPIO.BOARD) GPIO.setmode(GPIO.BOARD)
 GPIO.setup(ledPin, GPIO.OUT) GPIO.setup(ledPin, GPIO.OUT)
- 
 while True: while True:
-    time.sleep(1)     
     GPIO.output(ledPin, True)     GPIO.output(ledPin, True)
-    time.sleep(1)     + </code>
-    GPIO.output(ledPin, False) +
-</code>+
  
 Muutke koodi nii, et: Muutke koodi nii, et:
Line 118: Line 98:
 import RPi.GPIO as GPIO import RPi.GPIO as GPIO
 import time import time
- 
 sensorPin = 7 sensorPin = 7
- 
 GPIO.setmode(GPIO.BOARD) GPIO.setmode(GPIO.BOARD)
 GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
- 
-prevState = False 
-currState = False 
- 
 while True: while True:
-    time.sleep(0.1) +    time.sleep(0.1)             
-    prevState = currState +    print GPIO.input(sensorPin)
-    currState = GPIO.input(sensorPin+
-    if currState != prevState: +
-        newState = "1" if currState else "0" +
-        print "%s, %s" % (newState)+
  
 </code> </code>
Line 140: Line 110:
   - lisatakse reale kuupäev ja kellaaeg, ning tulemus kirjutatakse log-i faili.   - lisatakse reale kuupäev ja kellaaeg, ning tulemus kirjutatakse log-i faili.
   - tulemused näidatakse reaalajas graafiliselt (Vihje: Reaalaja graafilise väljundi tekitamiseks  kasuta kst tarkvara)   - tulemused näidatakse reaalajas graafiliselt (Vihje: Reaalaja graafilise väljundi tekitamiseks  kasuta kst tarkvara)
 +
 +https://www.raspberrypi.org/learning/parent-detector/worksheet/
raspi.1400160201.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0