Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Welcome to Small Basic!
  2. 'Below is a sample code to print 'Hello, World!' on the screen.
  3. 'Press Run(F5) for output.
  4. Sub Main
  5.   Program.Delay(4000)
  6.   Speaker.Play(100, "Sounds/Mirkan bog")
  7.   Motor.Start("A", 60)
  8.  
  9.  
  10.   code=0
  11.   x=1200
  12.   blok = 0
  13.   While "True"
  14.    
  15.     Program.Delay(1000)
  16.     optika()
  17.     If code=1 Then
  18.       pomak_naprijed()
  19.     Else
  20.       Motor.Stop("BC", "True")
  21.     EndIf
  22.    
  23.    
  24.    
  25.     ''dodir()
  26.    'If blok = 1 Then
  27.    'pomak_nazad()
  28.    'okret_desno()
  29.   'Else
  30.  
  31.  
  32.     'pomak_naprijed()
  33.   'EndIf
  34.   EndWhile
  35.  
  36.  
  37. EndSub
  38.  
  39. Sub pomak_naprijed
  40.   Motor.StartSync("BC", 50, 50)
  41.   Program.Delay(x)
  42.   Motor.Stop("BC","True")
  43. EndSub
  44.  
  45. Sub pomak_nazad
  46.   Motor.StartSync("BC",-50,-50)
  47.   Program.Delay(x)
  48.   Motor.Stop("BC","True")
  49. EndSub
  50.  
  51. Sub pomak_lijevo
  52.   Motor.Start("C",50)
  53.   Program.Delay(x)
  54.   Motor.Stop("B","True")
  55. EndSub
  56.  
  57. Sub pomak_desno
  58.   Motor.Start("B",50)
  59.   Program.Delay(x)
  60.   Motor.Stop("C","True")
  61. EndSub
  62.  
  63. Sub okret_lijevo
  64.   Motor.StartSync("BC",-50, 50)
  65.   Program.Delay(x)
  66.   Motor.Stop("BC","True")
  67. EndSub
  68.  
  69. Sub okret_desno
  70.   Motor.StartSync("BC",50, -50)
  71.   Program.Delay(x)
  72.   Motor.Stop("BC","True")
  73. EndSub
  74.  
  75. Sub optika
  76.  
  77.  Sensor.SetMode(4,1)
  78.  
  79.       LCD.StopUpdate()
  80.       LCD.Clear()
  81.       if Sensor.ReadPercent(4)<=50 Then
  82.         code=0
  83.       Else
  84.         code=1
  85.         EndIf
  86.        
  87.       Program.Delay(200)
  88. EndSub
  89.  
  90. Sub dodir
  91.  
  92.   Sensor.SetMode(3,0)
  93.   LCD.StopUpdate()
  94.   LCD.Clear()
  95.   If Sensor.ReadRawValue(3, 0) <= 25 Then
  96.     blok = 1
  97.     LCD.Text(1,15,55,2,"Stani lave!")
  98.   Else
  99.    
  100.    
  101.     blok = 0
  102.     LCD.Text(1,15,55,2,Sensor.ReadRawValue(3, 0)+" mm ")
  103.   EndIf
  104.   LCD.Update()
  105. EndSub
  106.  
  107.  
  108. Main()
  109. 'optika()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement